librasteve / raku-Dan

Top level raku Data ANalysis Module
Artistic License 2.0
7 stars 2 forks source link

df.sort: *<C> not working #19

Open librasteve opened 1 year ago

librasteve commented 1 year ago

Instaed of the given example...

say ~df.sort: { df[$++]<C> }; # sort by col C

Ideally would like to use examples such as:

say ~df.sort: *<C>;  
say ~df.sort: {.<C>}; 
say ~df.sort: {$_<C>};  

Which has been discussed over at Discord

https://discord.com/channels/538407879980482560/768511641758466088/1072494854325674075

p6steve: just to circle back on this - I have now had the time to review the implementation of role DataSlice in the Dan module and to check whether there is a simple fix to my code to get . or $_ working .... without going into the details, the status is (i) I agree that the current, working example for sort is a (bit of a) hack, (ii) DataSlice employs delegation and overloads so that it can mix Positional and Associative as "cascading accessors", this has about 80% coverage of the use cases, (iii) the issue arises because sort seems to coerce a DataSlice to an Array [which I guess is necessary to Iterate it] and this Array will not take , (iv) it is beyond my skill to identify a quick fix to dehack sort, (v) as the use cases for Dan (and it's brethren) solidifies, I would like to circle back and refactor this area (likely employing something like Hash::Agnostic / Array::Agnostic) to get the non-hacky sort syntax working, (vi) but since the hack will continue to work alongside a future "non-hackified" example I think that it's good enough for now because (vii) I am focusing my time to get Dan::Polars to MLP per the TODO lists(s) over there --- I have made an issue for this over at GH Dan and, as ever, will be happy to adapt my priorities according to comments/issues from users of Dan over on GH ...

librasteve commented 1 year ago

https://rakujourney.wordpress.com/2023/06/05/cascading-accessors/