# Thread: Sorting Arrays by enum

1. Member
Join Date
Nov 2009
Posts
2
Rep Power
0

## Sorting Arrays by enum

I need to make a sorting algorithm.

The program takes an input file that stores the information into an array: the array has student's name and a personality type.

The personality types are: enum values

Realistic
Artistic
Social
Conventional

Then once it takes an array, it sould divide the main array into 4 arrays with the personality types.

So the new array have all the same personality types and the students name.

Then I need it to divide the 4 arrays by a number. Then number can change at any time.

So it looks something like this

Mary Realistic
Lisa Artistic
Bill Artistic
Jake Realistic
Loren Conventional
Mike Social
Jessica Conventional
Rick Realistic
Karen Artistic
Lily Social
John Social

divides into four arrays

Array 1
Mary Realistic
Jake Realistic
Rick Realistic

Array 2
Lisa Artistic
Bill Artistic
Karen Artistic

Array 3
Lily Social
John Social
Mike Social

Array 4
Loren Conventional
Jessica Conventional

Then they select they want a group with 2 people

group 1
Mary, Jake

group 2
lisa, Bill

group3
lily, john

group4
loren, jessica

That leaves Rick, Karen, Mike.
so it places

group 5
Rick and Karen

and then place Mike in the first group with Mary and jake

so it would be

group 1
Mary, Jake, Mike

group 2
lisa, Bill

group3
lily, john

group4
loren, jessica

group 5
Rick and Karen

I know the problem is a little long, but I am not sure how to start on it. Any help is very well appreciated.

Thank You

2. Moderator
Join Date
Apr 2009
Posts
13,234
Rep Power
23
Break it down.
And turning the data in that into a bunch of Student objects.
So there's three classes to write there...one to read the file, one which represents a Student, and the third is the enum.

3. Member
Join Date
Nov 2009
Posts
2
Rep Power
0
thank you,

how do you turn the data into student objects? Can you please give an example?

4. Moderator
Join Date
Apr 2009
Posts
13,234
Rep Power
23
If you don't know that you really need to go back and look at your notes. Both at constructors and setters.

And then you can write some code. I assume you have written your Student class by now, since you're asking that question.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•