(Solved) SortStructuredList with nested List
Posted: Fri Aug 02, 2019 2:26 pm
Is this a bug or am I just doing something wrong?
I'd assume that following code will sort List a() and also ALL nested Lists a()\b() ascending. But only the first nested List gets sorted...
I'd assume that following code will sort List a() and also ALL nested Lists a()\b() ascending. But only the first nested List gets sorted...
Code: Select all
Structure SB
name$
EndStructure
Structure SA
name$
List b.SB()
EndStructure
Global NewList a.SA()
RandomSeed(1)
; fill
For i=2 To 0 Step - 1
AddElement(a())
a()\name$ = "Item " + Str(i)
For j=0 To 9
AddElement(a()\b())
a()\b()\name$ = Chr(Random(90, 65)) + Chr(Random(122, 97))
Next
Next
; sort
If 1
ForEach a()
SortStructuredList(a(), #PB_Sort_Ascending, OffsetOf(SA\name$), TypeOf(SA\name$))
ForEach a()\b()
SortStructuredList(a()\b(), #PB_Sort_Ascending, OffsetOf(SB\name$), TypeOf(SB\name$))
Next
Next
EndIf
; debug
ForEach a()
Debug a()\name$
ForEach a()\b()
Debug Chr(9) + a()\b()\name$
Next
Next