Correctify the first greedy algorithms,use 2 parameter for sorting