Doubt in editorial

why is sorting done on basis of 2nd int of pair in solution…?

current activity can be selected if the finish time of previous selected activity is less than or equal to the starting time of current activity.

so we are arranging them according to the ending time