You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are work-arounds which revolve around either the side-effect that sorting a struct appears to sort by fields in order so by (re)constructing the struct as {"value": 1, "key": "B"} sorts by value, or by exploding the struct, sorting and then re-grouping.
Ideally pl.Expr.list.sort would accept a sort key expression similar to how the python sorted function behaves.
If this is accepted I'd be inclined to implement for all sort methods?
The text was updated successfully, but these errors were encountered:
Yeah either works, @cmdlineluser I guess list.sort_by is easier to find (i.e it's explicit), but the workaround posted by @nameexhaustion example works for me as well.
Description
There doesn't appear to be a direct way to sort an array of structs by field, i.e.
Given:
Sort struct by value
There are work-arounds which revolve around either the side-effect that sorting a struct appears to sort by fields in order so by (re)constructing the struct as {"value": 1, "key": "B"} sorts by value, or by exploding the struct, sorting and then re-grouping.
Ideally pl.Expr.list.sort would accept a
sort key
expression similar to how the pythonsorted
function behaves.If this is accepted I'd be inclined to implement for all sort methods?
The text was updated successfully, but these errors were encountered: