SortStructuredArrayCustom and SortStructuredListCustom

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User_Russian
Addict
Addict
Posts: 1443
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

SortStructuredArrayCustom and SortStructuredListCustom

Post by User_Russian »

Need the functions SortStructuredArrayCustom and SortStructuredListCustom to sort by multiple fields of the structure.
For example.

Code: Select all

Structure Struct
  a.l
  b.u
EndStructure

Procedure SortCompare(*x.Struct, *y.Struct)
  If *x\a > *y\a Or (*x\a = *y\a And *x\b > *y\b)
    ProcedureReturn #True
  Else
    ProcedureReturn #False
  EndIf
EndProcedure

NewList MyList.Struct()

SortStructuredListCustom(MyList(), @SortCompare())
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: SortStructuredArrayCustom and SortStructuredListCustom

Post by Little John »

This has already been requested:
viewtopic.php?f=3&t=68690
Post Reply