Component Configurable Collection Sort wraps the method Sort() from ArrayList .NET class. The sort models are elements of comparator (implementing IComparer interface) called for each pair comparison done during QucikSort algorithm processing.
The comparator works for each pair in following way:
- Checks the identity of two elements
Identical => returns with equality result
Not identical => continues
- Checks the elements order using 1st level sort model
Not equal => returns with greater or less result
Equal => checks if highest sort level is 1: if yes returns with equality result, else continues
- Checks the elements order using 2nd level sort model
Not equal => returns with greater or less result
Equal => checks if highest sort level is 2: if yes returns with equality result, else continues
- Etc. analogical for further sorting models
Such implementation lets for sorting using more then one criterion e.g. sorting complex data types using more then one filed. For instance, an array built of complex type Person objects containing two fields FirstName and SecondName could be sorted alphabetically by field SecondName (inside 1st level sort model) and additionally for all elements having same value of SecondName could be sorted by filed FirstName (inside 2nd level sort model).
I'm not sure if it wolud be clear enough :-)