# Sort a RDataFrame

**URL:** <https://root-forum.cern.ch/t/sort-a-rdataframe/50739>\
**Category:** Newbie\
**Tags:** rdataframe\
**Created:** [July 9, 2022, 4:04pm UTC](https://root-forum.cern.ch/t/sort-a-rdataframe/50739 "2022-07-09T16:04:07Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [July 11, 2022, 1:52pm UTC](https://root-forum.cern.ch/t/sort-a-rdataframe/50739/3 "2022-07-11T13:52:05Z")

</div>

Hi @Yannis_Kingdom ,

and welcome to the ROOT forum! Indeed the thread you mention ([Sorting a DataFrame](https://root-forum.cern.ch/t/sorting-a-dataframe/31426)) stated the feature would be available in v6.18, but that was never actually implemented in RDataFrame itself, unfortunately. If your data fits in RAM, in Python you can export it to numpy arrays with `AsNumpy` (after RDF filtering and processing), then use `pandas` to sort the dataset, then if needed you can construct another RDataFrame from that pandas dataframe with

```python
arrs = {k: np.array(v) for k,v in pandas_df.to_dict().items()}
rdf = ROOT.RDF.MakeNumpyDataFrame(arrs)

```

It’s possible to do something similar in C++ but it requires a lot more code.

Cheers,  
Enrico

---

_[View the full topic](https://root-forum.cern.ch/t/sort-a-rdataframe/50739)._
