Use the code from whichever file controls listings with the sorting method you like. You need to look at the code in those files for yourself.