The sorting function was implemented.