Sorting 2D array in java

Discussion in 'Java' started by shilpa dessai, Mar 20, 2008.

  1. shilpa dessai

    shilpa dessai New Member

    Joined:
    Mar 20, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Hi, I've got a 2D array which I would like to sort into descending order according to the first column but keep the information in the 2nd column in the same row as the information in the first column no matter where the sort moves it to in the array. To explain more clearly:
    Supposing I had this 2D array:

    |5 1|
    |6 2|
    |3 3|
    |8 4|
    |2 5|

    I want my bubble sort to be able to sort it into:

    |8 4|
    |6 2|
    |5 1|
    |3 3|
    |2 5|

    All the info I've found on bubble sorts has only been about 1D arrays. Any help or a nudge in the right direction would be really appreciated!
    Regards
    shilpa
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Moved to Java forum
     
  3. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice