The list returned should be sorted in decreasing order


Write method in the MusicExchangeCenter class called uniqueDownloads() that returns (i.e., not displays) a TreeSet of all downloaded Song objects such that the set is sorted alphabetically by song title. There should be no duplicates songs in this set.

Write method in the MusicExchangeCenter class called songsByPopularity() that returns (i.e., not displays) an ArrayList of Pair objects where the key of the pair is an Integer and the value is the Song object. The integer key should represent the number of times that that song was downloaded. The list returned should be sorted in decreasing order according to the number of times the song was downloaded. To sort a list of Pair objects, you can use the following code:

Collections.sort(popular, new Comparator>() { public int compare(Pair p1, Pair p2) { // PUT YOUR CODE IN HERE } });

Just insert the missing code so that it returns an appropriate integer indicating whether pair p1 comes before or after pair p2 in the sort order

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: The list returned should be sorted in decreasing order
Reference No:- TGS02700037

Now Priced at $10 (50% Discount)

Recommended (95%)

Rated (4.7/5)