list: the list to be sorted
[direction:] the direction in which to sort the list. Can be either 'ascending or 'descending
[keyIndex:] if you have a list of lists and you want to sort by an element of a sublist, specify the keyindex of that element