4 Replies - 2006 Views - Last Post: 19 April 2011 - 10:03 PM Rate Topic: -----

#1 Teclis  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 19-April 11

Task: selection sort using four parallel arrays.

Posted 19 April 2011 - 09:49 PM

I'm not really sure how to proceed. I just am looking for a "start here" launch pad to sort a string array and then if something is moved- move the other three arrays accordingly. The examples of selection sort that I've seen and been provided use int and double; I get that. Doing it with a string is mind boggling to say the least.
Is This A Good Question/Topic? 0
  • +

Replies To: Task: selection sort using four parallel arrays.

#2 TFoSSDQ  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 123
  • View blog
  • Posts: 253
  • Joined: 09-December 10

Re: Task: selection sort using four parallel arrays.

Posted 19 April 2011 - 09:52 PM

Use objects, not parallel arrays, macosxnerd101 has a tutorial on that in the java tutorial section: Moving away from parallel arrays

This post has been edited by TFoSSDQ: 19 April 2011 - 09:53 PM

Was This Post Helpful? 1
  • +
  • -

#3 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10183
  • View blog
  • Posts: 37,596
  • Joined: 27-December 08

Re: Task: selection sort using four parallel arrays.

Posted 19 April 2011 - 09:54 PM

Take a look at the documentation for the String class. Strings are compared using the compareTo() method rather than the <, <=, >, and >= operators.

As an example:
String s = "123";
int compare = s.compareTo("234");



If compare < 0, then s < "234" so to speak. If compare == 0, then the two Strings are equal. Otherwise, s > "234" so to speak.

If you have to use parallel arrays, those are the constraints of your assignment. But as you get more into programming, you should really consider using classes and Objects instead. It is a more standards way of doing things.
Was This Post Helpful? 0
  • +
  • -

#4 Brewer  Icon User is offline

  • Awesome
  • member icon

Reputation: 178
  • View blog
  • Posts: 1,044
  • Joined: 14-June 10

Re: Task: selection sort using four parallel arrays.

Posted 19 April 2011 - 09:55 PM

Here is a code snippet by mostyfriedman demonstrating how to implement a selection sort in Java.

Start with what he has already written and figure out how you can apply this to arrays.
Was This Post Helpful? 0
  • +
  • -

#5 Teclis  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 19-April 11

Re: Task: selection sort using four parallel arrays.

Posted 19 April 2011 - 10:03 PM

Thanks for the tips guys.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1