Array Help

Joined
Nov 26, 2011
Messages
1
Reaction score
0
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.
:)
 
Joined
Dec 9, 2011
Messages
1
Reaction score
0
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top