Sort a RDataFrame

Hi @Yannis_Kingdom ,

and welcome to the ROOT forum! Indeed the thread you mention (Sorting a DataFrame) 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

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