Sorts list view items by using an application-defined comparison function.
This method changes the index of each item to reflect the new sequence.
The comparison function, pfnCompare, has the following form:
int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
The comparison function must return a negative value if the first item should precede the second, a positive value if the first item should follow the second, or zero if the two items are equal.
The lParam1 parameter is the 32-bit value associated with the first item that is compared, and the lParam2 parameter is the value associated with the second item. These are the values that were specified in the lParam member of the items' LVITEM structure when they were inserted into the list. The lParamSort parameter is the same as the dwData value.
This method sends the LVM_SORTITEMS message, which is described in the Windows SDK.
The following is a simple comparison function that results in items being sorted by their lParam values.