Left 4 Green: Problem with programming. - Left 4 Green

Jump to content

Toggle shoutbox Thu'umbox

Dr.Minky  : (24 May 2012 - 00:01) We've gota way of doing things around here
Dr.Minky  : (24 May 2012 - 00:00) Never seen you before
Dr.Minky  : (24 May 2012 - 00:00) Darkness? Hm?
Dr.Minky  : (23 May 2012 - 21:51) Lulz
Luke Nukem  : (23 May 2012 - 21:44) CTRL Y!!
rui_troia  : (23 May 2012 - 21:43) omfg, I accidently removed the map I was working in 2 hours and I have no clue where it is. I didnt saved it.... This is watchyer' get for pressing CTRL and X ad G-man...
Mr. Darkness  : (23 May 2012 - 21:39) you
Mr. Darkness  : (23 May 2012 - 21:39) Minky, who are you? I don't know.
Luke Nukem  : (23 May 2012 - 21:31) The suns butt fucked me.
rui_troia  : (23 May 2012 - 20:51) Hello Lads, ladies and headcrabs, I will work on my new CSS map.
Dr.Minky  : (23 May 2012 - 19:40) Mathijs, were you saying that in response to Frizzy's last comment?
Mathijs1996  : (23 May 2012 - 19:28) Why is it possible that one stranger's wish becomes reality without the known people agreeing (Sad face) :(
Frizzy  : (23 May 2012 - 19:07) "I'm so fresh you can suck my nuts"
Frizzy  : (23 May 2012 - 19:07) I would say...
Frizzy  : (23 May 2012 - 19:07) Hmmm
Dr.Minky  : (23 May 2012 - 19:04) srs
Dr.Minky  : (23 May 2012 - 19:04) http://www.youtube.com/watch?v=8UFIYGkROII&ob=av2e
Dr.Minky  : (23 May 2012 - 19:03) I'm actually soulja boy, I crank it every day
Dr.Minky  : (23 May 2012 - 19:02) What would you do, if I were to tell you..
Dr.Minky  : (23 May 2012 - 19:02) Frizzy
Resize Shouts Area
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Problem with programming.

#1 User is offline   MiF 

  • Feeling Haxxy
  • Pip
  • 9

Posted 11 July 2011 - 15:36

I have been stuck with problem about hour already, and without working solution, so i think it's time to ask for help.


Problem is this. I have 2 dimension array ( [inf.] [3] ) where first data is name (first and last name), second is age and third is city. Now i need to sort this array of data in order of age (from older to younger).

I am coding it in java, and i can use all libraries which come with java, but no outside ones.


There might be easy solution for this, but i am just locked up (as we say here in finland) :/

This post has been edited by MiF: 11 July 2011 - 15:37

+
Posted Image
0

#2 User is offline   Raptor 

  • Zombie Meat
  • 32

Posted 11 July 2011 - 21:20

Well, I only can help you by bumping this :(
Maybe the Programming Experts weren't on when your Topis was on the Front Page :C
+
Posted Image
0

#3 User is online   Clavus 

  • Game dev.
  • TopCrew
  • PipPipPipPipPipPipPipPip
  • 317

Posted 11 July 2011 - 21:28

What exactly is the problem? Are you searching for a sorting algorithm to use or can't you write decent java code in the first place.
+
Posted Image
Clavus Studios steam group (join it)
ಠ_ರೃ


Synchro Drive - Final Fantasy XIII-2
0

#4 User is offline   MrZunz 

  • Zombie Meat
  • Greens
    34

Posted 11 July 2011 - 21:35

First off all you need to store all those arrays, in an array...

This post has been edited by MrZunz: 11 July 2011 - 21:35

+
"Software is never finished, it is in varying states of 'less broken'" because "If it ain't broke, it doesn't have enough features yet"
0

#5 User is online   Clavus 

  • Game dev.
  • TopCrew
  • PipPipPipPipPipPipPipPip
  • 317

Posted 11 July 2011 - 21:37

Turning them into an ArrayList data structure is going to make your life a lot easier to begin with.
+
Posted Image
Clavus Studios steam group (join it)
ಠ_ರೃ


Synchro Drive - Final Fantasy XIII-2
0

#6 User is offline   MiF 

  • Feeling Haxxy
  • Pip
  • 9

Posted 11 July 2011 - 21:42

View PostClavus, on 11 July 2011 - 21:28, said:

What exactly is the problem? Are you searching for a sorting algorithm to use or can't you write decent java code in the first place.


I have alghorithm (which works). Problem itself is this;

i have this 2d array with this data (left to right is first dimension, up to down is second):

Attached File  array1.png (2.37K)
Number of downloads: 0

I need to sort it to this:

Attached File  array2.png (2.19K)
Number of downloads: 0

View PostClavus, on 11 July 2011 - 21:37, said:

Turning them into an ArrayList data structure is going to make your life a lot easier to begin with.


(Ninja'd)

Okey got to check that out ->
+
Posted Image
0

#7 User is offline   Kikkers 

  • Zombie Meat
  • 1

Posted 11 July 2011 - 22:51

1. make a class to contain your values
2. let that class implement the Comparable interface
3. implement the compareTo() method with your custom sorting

Now, by implementing Comparable, you can use some extra collection features such as this sort method for lists (that includes ArrayList) or this one for simple arrays

There are more ways to do it, like comparators, but they are functionally similar (and not any easier anyway). You should avoid writing your own sorting methods, as the java collection framework is already optimized.
0

#8 User is offline   Navo 

  • ADJUSTING MY POSITION
  • Greens
  • PipPipPip
  • 107

Posted 12 July 2011 - 00:22

I have absolutely no idea what people are talking about in this topic.
+
Posted Image
0

#9 User is offline   TechnoNegro 

  • Zombie Meat
  • 28

Posted 12 July 2011 - 01:17

i think i could understand that in other langue, like finnish or english.

This post has been edited by TechnoNegro: 12 July 2011 - 01:19

+
Hi.
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users