Array Help

Discussion in 'Java' started by tmantonym, Nov 26, 2011.

  1. tmantonym

    tmantonym

    Joined:
    Nov 26, 2011
    Messages:
    1
    Hey guys!

    I'm having a little trouble creating a leaderboard using simple code.
    I'm assuming an array is the way to go, because that's the only way I can think of going about storing alot of data which can be organised.

    Basically, I'm wondering how to sort an array using their records (hopefully the terminology is right).

    For example, say I have 3 players with 4 variables I want to store about those players individually:

    static public String player[][] = new String [3][4];

    How would I go about sorting the [3] arrays by their 4th record?

    Thanks.
    :)
     
    tmantonym, Nov 26, 2011
    #1
    1. Advertising

  2. tmantonym

    rankintoday

    Joined:
    Dec 9, 2011
    Messages:
    1
    your idea of an array is off--somewhat.. you are saying that 'player' is a 2 dimensional array..

    I think you need a 1 dimensional array.
    the '4' does not tell it how many variables the player has.

    umm .. a quick solution would just to
    make a class called Player ... and have it store your 4 variables..
    make some getters for them variables

    then create your 1 dimensional array of Player ..
    store the # of players you need.
    then sort by which ever 'variable' you need.
     
    rankintoday, Dec 9, 2011
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. stelladiary2004@hotmail.com

    [help] How to copy fast an array to another array?

    stelladiary2004@hotmail.com, Aug 11, 2004, in forum: C++
    Replies:
    4
    Views:
    13,514
    Old Wolf
    Aug 13, 2004
  2. Eric Boutin
    Replies:
    7
    Views:
    461
  3. Mara Guida

    const and array of array (of array ...)

    Mara Guida, Sep 2, 2009, in forum: C Programming
    Replies:
    3
    Views:
    512
    David RF
    Sep 3, 2009
  4. Tom
    Replies:
    3
    Views:
    228
    salsablr
    Dec 20, 2004
  5. Tuan  Bui
    Replies:
    14
    Views:
    507
    it_says_BALLS_on_your forehead
    Jul 29, 2005
Loading...

Share This Page