The sorting function now ensures that the sort params array is instantiated before use.