Can you include a change to treat null/undefined (e.g. missing sort field in few objects from the array being sorted) as a usual value. Currently in such case, the final sorted output seems random.
A quick fix I tried which worked for my case, was to change the comparison line of code as follows, so that the null values appear first for ascending sort and last for descending sort.
comparator = (reducedA||'') > (reducedB||'') ? 1 : -1;
But maybe there is a better or configurable way to achieve it
Can you include a change to treat null/undefined (e.g. missing sort field in few objects from the array being sorted) as a usual value. Currently in such case, the final sorted output seems random.
A quick fix I tried which worked for my case, was to change the comparison line of code as follows, so that the null values appear first for ascending sort and last for descending sort.
comparator = (reducedA||'') > (reducedB||'') ? 1 : -1;But maybe there is a better or configurable way to achieve it