Added sort function.