////
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
////
:documentationPath: /pipeline/transforms/
:language: en_US
:description: The Sort Rows transform sorts rows based on the fields you specify and on whether they should be sorted in ascending or descending order.

= image:transforms/icons/sortrows.svg[Sort Rows transform Icon, role="image-doc-icon"] Sort Rows

[%noheader,cols="3a,1a", role="table-no-borders" ]
|===
|
== Description

The Sort Rows transform sorts rows based on the fields you specify and on whether they should be sorted in ascending or descending order.

The transform optionally only pass unique records, based on the sort keys.

TIP: You use can use multiple copies of the Sort Rows transform to speed up large sort operations. Make sure to add a xref:pipeline/transforms/sortedmerge.adoc[Sorted Merge] transform after the sort to correctly merge the streams of sorted that are generated by the various sort copies.

|
== Supported Engines
[%noheader,cols="2,1a",frame=none, role="table-supported-engines"]
!===
!Hop Engine! image:check_mark.svg[Supported, 24]
!Spark! image:cross.svg[Not Supported, 24]
!Flink! image:cross.svg[Not Supported, 24]
!Dataflow! image:cross.svg[Not Supported, 24]
!===
|===

== Options

[options="header"]
|===
|Option|Description
|Transform name|Name of the transform, this name has to be unique in a single pipeline.
|Sort directory|The directory in which the temporary files are stored in case when needed; the default is the standard temporary directory for the system
|TMP-file prefix|Choose an easily recognized prefix so you can identify the files when they show up in the temp directory.
|Sort size|The more rows you store in memory, the faster the sorting process because fewer temporary files must be used and less I/O is generated.
|Free memory threshold (in %)|If the sort algorithm finds that it has less available free memory than the indicated number, it will start to page data to disk.
|Compress TMP Files|Compresses temporary files when they are needed to complete the sort.
|Only pass unique rows?|Enable if you want to pass unique rows only to the output stream(s).
|Fields table|Specify the fields and direction (ascending/descending) to sort.
You can specify whether to perform a case sensitive sort (optional)
|Get Fields|Click to retrieve a list of all fields coming in on the stream(s).
|===
