codesamples:sorting_collection_delegate
This is an old revision of the document!
Sorting an object collection using a delegate
class Person constructor( cName as string ) self:Name := cName return public property Name as string auto end class
local oPersons as List<Person>
oPersons := List<Person>{}
oPersons:Add( Person{ "Robert" } )
oPersons:Add( Person{ "Fabrice" } )
oPersons:Add( Person{ "Chris" } )
oPersons:Add( Person{ "Nikos" } )
oPersons:Sort( ;
delegate( o1 as Person, o2 as Person ) {
local nResult as int
nResult := o1:Name:CompareTo( o2:Name )
return nResult
} ;
)
P.S. this code currently compiles only in Core dialect, not in VO dialect
codesamples/sorting_collection_delegate.1773831125.txt.gz · Last modified: 2026/03/18 10:52 by wolfgangriedmann