September 2017
Intermediate to advanced
216 pages
6h 8m
English
You can preserve the order of the first set by transforming it to an ordered set:
const myOrderedIntersection = myFirstSet .sort() .intersect(mySecondSet);console.log('myOrderedIntersection', myOrderedIntersection.toJS());// -> myOrderedIntersection [ 2, 4, 6 ]
This works because myFirstSet is now an ordered set. When you sort it, it returns an OrderedSet which remains sorted when the intersect() method iterates over it.
Read now
Unlock full access