Actually i always get stucked in the compare function

how does these signs work? could you explain with example that in which case swapping occurs and which case is not??? and why? actually what function returns and all ??

please tell me example and code acc to java

Hi @Muskan-Gupta-598128740703036

This is the basic approach to apply greedy algorithm on activity selection problem. You can verify it yourself by taking example and then try to solve it using both sorting starting time and sorting finishing time. Lets take an example that there is an activity that starts at time 0 but finishes at time n. Where as there is an activity which start at time t = 1 but finishes at time t = 2. Hence we would be able to choose more of the left activities in case 2. Hence we do sorting on basis of finishing time and not starting time. And then greedily count the number of possible activities.

Hope it Helps.