I have a multidimensional array. The primary array is an array of
[publicationID][publication_name][ownderID][owner_name]
What I am tryin
I have just published to npm a micro-library called sort-helper (source on github). The idea is to import the helper by
to create the comparison function for sort
array method through the syntax items.sort(by(column, ...otherColumns))
, with several way to express the columns to sort by:
persons.sort(by('lastName', 'firstName'))
,dates.sort(by(x => x.toISOString()))
,[3, 2, 4, 1].sort(by(desc(n => n)))
→ [3, 2, 1, 0]
,['B', 'D', 'c', 'a'].sort(by(ignoreCase(x => x))).join('')
→ 'aBcD'
.It's similar to the nice thenBy mentioned in this answer but with the following differences that may be more to the taste of some:
thenBy
fluent API),