---
source: https://iinventedlight.com/library/notes/hf-datasets-sort-shuffle-select.md
title: "Sort, shuffle and select rows in Hugging Face Datasets"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (huggingface/datasets docs); restated in our own words"
attribution: "Summary by iinventedlight (AI-assisted). Sources: Hugging Face (Datasets docs), Process · Hugging Face, Apache-2.0 (huggingface/datasets docs); Hugging Face, Know your dataset, Apache-2.0 (huggingface/datasets docs)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-04
status: published
checked_on: 2026-11-05
as_of: 2026-11-05
confidence: medium
untested: "No code was run; only the fetched Hugging Face documentation pages were read."
category: huggingface-datasets
topic_area: "datasets: processing"
tags: huggingface, datasets, shuffle, select
sources:
  - id: S1
    title: "Process · Hugging Face"
    publisher: Hugging Face (Datasets docs)
    url: https://huggingface.co/docs/datasets/process
    accessed: 2026-11-05
    license: "Apache-2.0 (huggingface/datasets docs)"
  - id: S2
    title: "Know your dataset"
    publisher: Hugging Face
    url: https://huggingface.co/docs/datasets/access
    accessed: 2026-11-05
    license: "Apache-2.0 (huggingface/datasets docs)"
    license: "Apache-2.0 (huggingface/datasets docs)"
---
# Hugging Face Datasets: sort, shuffle, select

## Short answer
`sort`, `shuffle`, and `select` rearrange a dataset and return a new `Dataset`. Shuffling uses a fast approximate indices mapping. [S1]

## Points
- Processing methods return a new dataset object. [S1]
- `select` keeps rows by a list of indices. [S1]
- Indexing into a dataset returns a dict for that row. [S2]

## Claims
- id: C1
  claim: Processing methods return a new Dataset.
  source: S1
  evidence: "All processing methods in this guide return a new Dataset object"
- id: C2
  claim: select returns rows for a list of indices.
  source: S1
  evidence: "returns rows according to a list of indices"
- id: C3
  claim: Shuffle uses a fast approximate indices mapping.
  source: S1
  evidence: "leverage its fast approximate shuffling"
- id: C4
  claim: Row indexing returns a dictionary example.
  source: S2
  evidence: "indexing by the row returns a dictionary of an example from the dataset"

## Sources
- [S1] Process · Hugging Face. Hugging Face (Datasets docs). https://huggingface.co/docs/datasets/process . License: Apache-2.0 (huggingface/datasets docs). Accessed 2026-11-05.
- [S2] Know your dataset. Hugging Face. https://huggingface.co/docs/datasets/access . License: Apache-2.0 (huggingface/datasets docs). Accessed 2026-11-05.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).

Source notice: Hugging Face Datasets documentation, Apache License 2.0 (https://github.com/huggingface/datasets/blob/main/LICENSE).
