Hi all,

I'm doing sentence scoring.

Let say,i have a paragraph with several sentences.Each sentence has a score(type double).

Hi,I'm programming java (this sentence score:1.2)
It's nice to code (this sentence score:0.3)
Not so nice when having problem (this sentence score:0.8)

What kind of structure should i use to ease the sorting(using java.util imports) so that the sentences would be sorted according to the scores(the final sorting of sentences and the corresponding scores must be stored)?

Thanks and regards.

Note:This is just an example,I may have hundreds of sentences.

Recommended Answers

All 2 Replies

Have a look at java.util.TreeMap

Two options:
- Use a third-party collections library like Apache collections/Google Collections
- Use a TreeMap with a custom comparator (TreeMap by default keeps "keys" sorted and not values)

Also, read this.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.