These are chat archives for ramda/ramda

Jul 2016
Brad Compton (he/him)
Jul 31 2016 01:26


Given an array of objects, using ramda how can I return a new array where any object that pass this test R.has('name'); gets moved to the start of the array?

Sounds like you want to use partition and then concat the two lists maybe?

Brad Compton (he/him)
Jul 31 2016 01:33

using evolve can I reference one field in another inside the transformation?

evolve loses the context of the surrounding object. Lenses might help, but I'm not sure.

James Forbes
Jul 31 2016 01:53

@ram-bot @bgvianyc

R.sortBy( R.complement(R.has('name')),[
  {something: 'hello'}
  , {  name: 'yes' }
  , {something:' hello'}
  , {name: 'yes'}

Taking advantage of false < true as a comparator

But it depends if you want the existing order to be retained for the other items. Might help?
Barry G
Jul 31 2016 02:23
thats elegant
James Forbes
Jul 31 2016 03:15
thank you, I kind of consider it a hack, but hopefully it works for your scenario