Solution to MakeSchool's sorting exercise