Sort AND Group by Key

Hi,

Is there a way to sort the groups that the “Group by Key” node returns? For some reason, it doesn’t sort them naturally the way the “Sort by Key” node does, even if the list of keys was first sorted before passing to it.

I could think of one way to do it, which is sort the list of keys, pass it to a sort by key node, and then count the number of occurrences of the keys, and chop the sorted list by those lengths (refer to screenshot below). But that feels like an unnecessarily redundant way to do it. Is there a better way?

there is a node for sorting and grouping in the Orchid package, dont know if you kan use that

1 Like

I specifically installed Orchid moments before I posted the question because I remember reading somewhere about that node. Though once I did install it, I couldn’t find that node! What’s it called?

In the meantime, I accidentally discovered ampersand has a node called [&] List.GroupByKey that has a sort keys option built in.

it is in the image above… but here is only that node :slight_smile:
Capture

1 Like

Oh, now I see why I couldn’t find it, haha. Turns out I didn’t actually install it. :man_facepalming:
I only looked through the right-click search at first. Thanks!

orchid%20install

1 Like