Help sorting/char arrays only

My brain is fried. I have been trying this all day. Everyone I seek help from ends up confusing me more because they solve it using concepts I don't know and that I am not allowed to use.

Heres a simplified version:

I need to take a two dimensional array of chars, sort ONLY THE PRECEDENCE of the ROWS by alphabetical order, while not actually sorting the rows themselves. Example:



Needs to be sorted to:


I am reading the char array in from a file.

I AM NOT ALLOWED to use vectors, or pointers. I have to use char array only. I am pretty sure we aren't even allowed to use strings either. So I would prefer to avoid them.

Sorry to post so much on this topic, maybe I should just walk away from it for a few hours. But given I have been more clear on this post, I am hoping someone could bring the correct information to me.

There are two things: what to do and how to do it.

What sorting algorithms do you know? Sorting is a what.

What if you had to sort a mere char array[5] = { 'a', 'k', 'b', 'q', 'c' }; How would you do that?

Syntax for doing it for a 2D array of characters is a how.

Sorting makes use of two operations: a test A<B and a change of order swap(A,B). This is where handling your rows differs from plain chars.
And to add to that, since you don't have plain chars you need a function for both the test and the swap operation.

EDIT: So think about those first. Maybe write the swap function first since it's probably easier.
Last edited on
Topic archived. No new replies allowed.