Sort ListView by clicking on columns

First of all, set ListView to vsReport style and fill in some data. OnColumnClick and OnCompare events will do the rest.
We need two more global variables – Descending (boolean type) to store the order of sorting, and SortedColumn to keep the number of column by which is the ListView sorted.

SortType parameter could have these values:

  • stNone
  • stData
  • stText
  • stBoth