std:sort compare funtion
Before writing the comparator function for sorting you must read this blog , otherwise, it hurts you hard in the contest. for more