Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am making a text summarization algorithm for my latest app and I am converting the code from python to java. I am stuck on the last part tough. in python they sort the sentences based on the score of the sentences and reverse it.

Code:

Python
sentences.sort(key=lambda s: sentence_score(s, frequencies), reverse=1)


In java I have the sentences array and the score from the sentences. I need to sort the sentences like this .sort(sentencesScore, descending) but I dont really know how to.

Any help would be much appreciated, thanks
Posted
Updated 4-Jul-18 21:40pm

 
Share this answer
 
Quote:
Collections.sort(list, Collections.reverseOrder());


or

CustomComparator

Quote:
Collections.sort(list, Collections.reverseOrder(new CustomComparator());
 
Share this answer
 
Comments
CHill60 5-Jul-18 3:54am    
Apart from the fact this question was answered 3 years ago, just "quoting" uncredited lines of code is not helpful nor clear.
Stick to answering new questions where the OP still needs help, and try adding some words to your solutions

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900