> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vectorshift.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Sort CSV Node

> Sort a CSV file

<img src="https://mintcdn.com/vectorshift/B2X2zpDX7crEnhCG/images/platform/pipelines/data-transformation/sort-csv.png?fit=max&auto=format&n=B2X2zpDX7crEnhCG&q=85&s=a357340ff5a3659710b4add03b1eddd0" alt="Sort CSV" width="468" height="315" data-path="images/platform/pipelines/data-transformation/sort-csv.png" />

This node allows you to sort a CSV file.

## Node Inputs

1. File to sort: The CSV you want to sort
   * Type: `File`

For providing the file you have two options:

1. If toggle is on Upload: Upload a file by clicking the upload button
2. If toggle is on Variable: Reference files from other nodes.

## Node Parameters

On the face of the node:

1. Has Headers: Turn on if the CSV has headers
2. Reverse Sort: Turn on if you want to sort in descending order. The sorting is done in ascending order by default.

If CSV has headers:

* Column to sort by: Select the column you want to sort the CSV by.

If CSV has no headers:

* Column Index: The index of the column to sort by (the first column is 0)

## Node Outputs

1. Output: The sorted CSV
   * Type: `File`
   * Example usage: `{{sort_csv_0.output}}`

## Example

The below example shows a pipeline that takes in a CSV file and sorts it.

1. File Node: Loads the CSV file
   * File: `File.csv` file created in the [CSV Writer Example](/platform/pipelines/data-transformation/file/csv-writer#example)
2. Sort CSV Node: Sorts the CSV file (reverse sort based on first column)
   * File to sort: `{{file_0.file}}`
   * Reverse Sort: `True`
   * Column Index: `0`
3. Output Node: Displays the sorted CSV file
   * Output: `{{sort_csv_0.output}}`

<img src="https://mintcdn.com/vectorshift/B2X2zpDX7crEnhCG/images/platform/pipelines/data-transformation/sort-csv-example.png?fit=max&auto=format&n=B2X2zpDX7crEnhCG&q=85&s=a9ca4c9f4e2df74b9894e263a8e08f84" alt="Sort CSV Example" width="1907" height="833" data-path="images/platform/pipelines/data-transformation/sort-csv-example.png" />

Initial CSV File

<img src="https://mintcdn.com/vectorshift/PSG1OGMwi51Mi0EL/images/Screenshot2025-04-13at8.53.51PM.png?fit=max&auto=format&n=PSG1OGMwi51Mi0EL&q=85&s=26e0d93ea7a82a82c0ce42980f826550" alt="Screenshot2025 04 13at8 53 51PM Pn" width="1466" height="690" data-path="images/Screenshot2025-04-13at8.53.51PM.png" />

Sorted CSV File <img src="https://mintcdn.com/vectorshift/B2X2zpDX7crEnhCG/images/platform/pipelines/data-transformation/sort-csv-example-2.png?fit=max&auto=format&n=B2X2zpDX7crEnhCG&q=85&s=b5d80b6ddc573226cc82991d50032293" alt="Sort CSV Example" width="919" height="805" data-path="images/platform/pipelines/data-transformation/sort-csv-example-2.png" />
