Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: [ask] about sorting number.

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Thanked 0 Times in 0 Posts

    Default [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
    public class Dblsrt {
        public static void main(String[] args) {
            //... 1. for letter
            Integer[] names = {"Z", "A", "D"};
            //... 2.for words.
            double[] lengths = {0,123.99};
    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

  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Thanked 833 Times in 772 Posts
    Blog Entries

    Default Re: [ask] about sorting number.

    This tutorial may help: Object Ordering (The Java™ Tutorials > Collections > Interfaces)

Similar Threads

  1. Sorting/Lexicographic =)
    By jcs990 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: March 12th, 2010, 11:19 PM
  2. Sorting an Array
    By Prince_85 in forum Algorithms & Recursion
    Replies: 2
    Last Post: February 21st, 2010, 03:00 PM
  3. thread sorting
    By thanos_ in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 12th, 2010, 06:23 PM
  4. [SOLVED] sorting
    By kite98765 in forum Algorithms & Recursion
    Replies: 8
    Last Post: February 4th, 2010, 08:34 AM
  5. Sorting Algorithms
    By Dalisra in forum Java Programming Tutorials
    Replies: 1
    Last Post: November 10th, 2009, 09:24 PM