Wolfram wrote:This does't work.
You sort by firstname and than you make a new sort by lastname.
I need this result.
"Anton, Smith"
"Paul, Amason"
"Paul, Simon"
I gave a general solution so that you could adapt it not only to this problem but to any in the future.
Notice this comment in the code:
Code: Select all
;sort in the reverse ordering of the keys, i.e. first key = lastName, second key = firstName, etc.
SortStructuredList(user(), #PB_Sort_Ascending, OffsetOf(userStruc\firstName), #PB_String)
SortStructuredList(user(), #PB_Sort_Ascending, OffsetOf(userStruc\lastName), #PB_String)
You apparently wanted: first key = firstName, second key = lastName.
This means you wanted things sorted by 'firstName', then when those match, by 'lastName'. They can individually be either in ascending or descending order, however you need it. If you needed further sorting by additional keys, and they were part of the same structure, you could do any of those as well as a third key, fourth key etc..
You would thus use:
Code: Select all
SortStructuredList(user(), #PB_Sort_Ascending, OffsetOf(userStruc\lastName), #PB_String) ;second key
SortStructuredList(user(), #PB_Sort_Ascending, OffsetOf(userStruc\firstName), #PB_String) ;first key
ForEach user()
Debug user()\firstName + ", " + user()\lastName
Next