Ah, I messed up, UndefinedSorter must not be chained, it must be a wrapper!Otherwise comparing to nil will resort to sorting by properties and fail...������ SortFunction>>undefinedFirst�������������� ^UndefinedSorter descending wrap: self������ UndefinedSorter>> collate: value1 with: value2������������ "sort all nil according to the direction (first if -1, last if +1), then"�������������� value1 ifNil: [value2 ifNil: [^0] ifNotNil: [^direction]].�������������� value2 ifNil: [^direction negated].�������������� ^sorterForNonNil collate: value1 with: value2It's important to have the UndefinedSorter :������ - decoupled from property sort, because it can be generally usefull������ - collating 2 nil as 0, so that another property can be chained
InvertedSortFunction>>collate: value1 with: value2�� �� ^(actualSortFunction collate: value1 with: value2) * -1
In������ people sortBy: #name ascending undefinedFirst , #age descendingwe could then have people with name nil still sorted by age, what is not possible with current implementation