| |

VerySource

 Forgot password?
 Register
Search
View: 1429|Reply: 14

java sort method?

[Copy link]

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-2-11 15:00:01
| Show all posts |Read mode
Please help with the help, thank you!
Reply

Use magic Report

0

Threads

6

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 Invalid IP Address

Post time: 2020-4-7 12:00:01
| Show all posts
How do you want to sort and spread? say clearly
Reply

Use magic Report

0

Threads

18

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-4-7 14:00:01
| Show all posts
Arrays.sort (...);
Just look at the api, there are many kinds
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-4-8 09:00:01
| Show all posts
I found the scores of the indefinite number of people from the 15 tables in the database (the number is variable), first add the scores belonging to each person (it is int), and then sort the scores of everyone Enough to use the sort () of the arrays, I searched for useful collections. I have never used it. I do n’t know which one to use. If the selection is not good, the loop may die. Understand!
Reply

Use magic Report

0

Threads

6

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 Invalid IP Address

Post time: 2020-4-8 13:45:01
| Show all posts
collections works great
Reply

Use magic Report

0

Threads

7

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-4-9 03:45:02
| Show all posts
After determining the number of people, how much ARRAY do you think create,

Why can't it be used? ? ? ? ?
Reply

Use magic Report

0

Threads

21

Posts

19.00

Credits

Newbie

Rank: 1

Credits
19.00

 Invalid IP Address

Post time: 2020-4-9 14:30:01
| Show all posts
Compare method for overloaded elements
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-4-9 15:15:01
| Show all posts
You can use Collections.sort (list, new Comparator () {
  public int compare (Object o1, Object o2) {
    MyPerson p1 = (MyPerson) o1;
    MyPerson p2 = (MyPerson) o2;
    return p1.getScore ()-p2.getScore ();
  }
});
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-4-10 21:30:01
| Show all posts
Thezxg121(meter) method is very practical. I will try it first, but I do n’t know how the comparison rules are set. I want to sort them in descending order by score.
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-4-11 00:00:02
| Show all posts
Comparator is the rule, how to use it? Thanks
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list