Faster sorting for single key items
MEMBER
`Dataset.sort` essentially does the same thing except it uses `pyarrow.compute.sort_indices` which doesn't involve copying the data into python objects (saving memory)

```python
sort_keys = [(col, "ascending") for col in column_names]
indices = pc.sort_indices(self.data, sort_keys=sort_keys)
return self.select(indices)
```
2023-08-18T13:45:13Z
https://github.com/huggingface/datasets/issues/6151#issuecomment-1683944655
https://api.github.com/repos/huggingface/datasets/issues/6151
IC_kwDODunzps5kXvTP
https://api.github.com/repos/huggingface/datasets/issues/comments/1683944655/reactions
2023-08-18T13:45:13Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1683944655
https://avatars.githubusercontent.com/u/42851186?v=4
https://api.github.com/users/lhoestq/events{/privacy}
https://api.github.com/users/lhoestq/followers
https://api.github.com/users/lhoestq/following{/other_user}
https://api.github.com/users/lhoestq/gists{/gist_id}
https://github.com/lhoestq
lhoestq
MDQ6VXNlcjQyODUxMTg2
https://api.github.com/users/lhoestq/orgs
https://api.github.com/users/lhoestq/received_events
https://api.github.com/users/lhoestq/repos
https://api.github.com/users/lhoestq/starred{/owner}{/repo}
https://api.github.com/users/lhoestq/subscriptions
User
https://api.github.com/users/lhoestq
public
NONE
Ok interesting, I'll continue debugging to see what is going wrong on my end.
2023-08-21T14:38:25Z
https://github.com/huggingface/datasets/issues/6151#issuecomment-1686458638
https://api.github.com/repos/huggingface/datasets/issues/6151
IC_kwDODunzps5khVEO
https://api.github.com/repos/huggingface/datasets/issues/comments/1686458638/reactions
2023-08-21T14:38:25Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1686458638
https://avatars.githubusercontent.com/u/47942453?v=4
https://api.github.com/users/jackapbutler/events{/privacy}
https://api.github.com/users/jackapbutler/followers
https://api.github.com/users/jackapbutler/following{/other_user}
https://api.github.com/users/jackapbutler/gists{/gist_id}
https://github.com/jackapbutler
jackapbutler
MDQ6VXNlcjQ3OTQyNDUz
https://api.github.com/users/jackapbutler/orgs
https://api.github.com/users/jackapbutler/received_events
https://api.github.com/users/jackapbutler/repos
https://api.github.com/users/jackapbutler/starred{/owner}{/repo}
https://api.github.com/users/jackapbutler/subscriptions
User
https://api.github.com/users/jackapbutler
public
### Feature request

A faster way to sort a dataset which contains a large number of rows.

### Motivation

The current sorting implementations took significantly longer than expected when I was running on a dataset trying to sort by timestamps. 

**Code snippet:**
```python
ds = datasets.load_dataset( "json", **{"data_files": {"train": "path-to-jsonlines"}, "split": "train"}, num_proc=os.cpu_count(), keep_in_memory=True) 
sorted_ds = ds.sort("pubDate", keep_in_memory=True)
```

However, once I switched to a different method which
1. unpacked to a list of tuples
2. sorted tuples by key
3. run `.select` with the sorted list of indices
It was significantly faster (orders of magnitude, especially with M's of rows)

### Your contribution

I'd be happy to implement a crude single key sorting algorithm so that other users can benefit from this trick. Broadly, this would take a `Dataset` and perform;

```python
# ds is a Dataset object
# key_name is the sorting key

class Dataset:
   ...
   def _sort(key_name: str) -> Dataset:
      index_keys = [(i,x) for i,x in enumerate(self[key_name])]
      sorted_rows = sorted(row_pubdate, key=lambda x: x[1])
      sorted_indicies = [x[0] for x in sorted_rows]
      return self.select(sorted_indicies)
```