Sort function and list