These are chat archives for ramda/ramda

13th
Oct 2016
Ryan Zeigler
@rzeigler
Oct 13 2016 01:12
i suspect what your looking for is actually compose(multiply(-1), predicate)
LeonineKing1199
@LeonineKing1199
Oct 13 2016 04:16
Ha, good catch!
For some reason I'm not used to the sort not being a sortByBooleanPredicate
Ryan Zeigler
@rzeigler
Oct 13 2016 13:55
actually, i've been thinking about it some more, and one that that sortBy doesn't really allow is inverting the ordering
but you can use converge to generate a sorter
LeonineKing1199
@LeonineKing1199
Oct 13 2016 15:27
How do you mean? I had to read the MDN and apparently it seems like JS uses somewhat normal conventions but eschews the use of a boolean so that when you return 0, you preserver stability. So it seems like your compose((x) => -x, predicate) is the appropriate solution for inverting a sort
I realized it's actually fewer characters to use the arrow function :P
Ryan Zeigler
@rzeigler
Oct 13 2016 18:43
i was just refering to R.sortBy
which makes inversion difficult
but you can approximate something like converge(compose(multiply(-1), comparator), prop('a'), prop('a'))
LeonineKing1199
@LeonineKing1199
Oct 13 2016 21:01
converge might be overkill but that seems right to me. I haven't written any tests yet but if sorting uses < 0, === 0 and > 0 then a (* -1) should work out great