[ask] about sorting number.
before i start my question, i want to say sorry if i ask too much in this forum.
and i want to thanks to peoples here that let me asking in this forum. because i can learn fast through asking, not from reading. but i try.
ok..now, i want to ask about sorting letter with number together.
what i know is just sorting number and letter in different method
Code :
public class Dblsrt {
public static void main(String[] args) {
//... 1. for letter
Integer[] names = {"Z", "A", "D"};
Arrays.sort(names);
System.out.println(Arrays.toString(names));
//... 2.for words.
double[] lengths = {0,123.99};
Arrays.sort(lengths);
System.out.println(Arrays.toString(lengths));
}
}
Code :
for that code above, the input will be show like this:
[A, D,Z]
[0, 99, 123]
but, what i want to learn is how to sorting data like: Alison, with value: 0 (Alison, 0). <--i dont know how to call this situation.
in other words, the output will be sorted from higher number, not from small number and not from letter. for example output:
1st> i input Alison, with value: 0.
then, 2nd> i input Zoe, with value: 120.
lastly, 3rd> i input David, with value: 99.
then the output will be displayed like this:
1> Zoe, 120
2> David, 99
3>Alison, 0
Re: [ask] about sorting number.