Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Ask Reuben 21 - Multi-Column Sorting  (Read 5375 times)
Reuben B.
Four Js
Posts: 1116


« 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/

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines