Title: Ask Reuben 21 - Multi-Column Sorting Post by: Reuben B. on May 12, 2020, 09:06:08 am How can I sort on multiple columns? How are ties broken when sorting in Genero?
To answer how to sort on multiple columns, it is necessary to understand how ties are broken. When doing a sort by clicking on a table column header, ties are broken by the order in the underlying array variable. The position in the underlying array variable does not change, hence a sort is independent of previous sorts. When doing a sort using the array.sort method, ties are broken by the position in the array before the sort. The position in the underlying array variable does change, hence a sort is dependent on previous sorts. To sort on multiple columns, call the array.sort() method multiple times, sorting on the least significant column first up to the most significant column last. OR alternatively populate a phantom column with a unique sort value and call the sort method once on this phantom column. Read more at https://4js.com/ask-reuben/ig-21/ |