How to make an Excel-Like Sort By A, Then By B in a TObjectList<> using multiple comparers

前端 未结 3 1157
离开以前
离开以前 2021-02-01 20:23

I have just started to use generics, and I am currently having a problem doing sorting on multiple fields.

Case:
I have a PeopleList as a TObjectList

3条回答
  •  情书的邮戳
    2021-02-01 20:53

    If you have a stable sorting algorithm, then you can apply each comparer in reverse order, and the result will be a list sorted in the order you desire. Delphi's list classes use quick sort, which is not a stable sort. You'd need to apply your own sorting routine instead of the built-in ones.

提交回复
热议问题