Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Sorting a 2 dimensional array

Reply
Thread Tools

Sorting a 2 dimensional array

 
 
Todd
Guest
Posts: n/a
 
      04-06-2004
I'm new to c++ and was wondering how to sort a 2 dimensional array. I'm
using a select sort for 1 dimensional arrays but it is not working for a 2
dimensional array. The 2 dimensional array are float elements. Thanks in
advance


 
Reply With Quote
 
 
 
 
Howard
Guest
Posts: n/a
 
      04-06-2004

"Todd" <fthdg> wrote in message news:...
> I'm new to c++ and was wondering how to sort a 2 dimensional array. I'm
> using a select sort for 1 dimensional arrays but it is not working for a 2
> dimensional array. The 2 dimensional array are float elements. Thanks in
> advance
>
>


You don't specify anything at all about what you expect the results to be
after sorting your 2D array. I'm not sure exactly what it means to sort a
2D array!

You can easily sort each row (or column, whatever), but then what? Must
every element in the next row be greater (or less) than every element in the
preceding row? Or is there some other criteria for what you desire? Is it
a sparse array? Are elements allowed (or supposed) to move between columns
as well as rows? See my problem? If you have a clear definition of the
problem and its restrictions, the answer will likely be easy to see.

Try working a small example on paper first, and that may help.

By the way, this is not so much a C++ question as an algorithm question.
Once you have a design, and implement it in C++ code, we can surely help you
correct that code if it's giving you problems. But we can also help point
you in the right direction initially, provided we have enough info.

-Howard


 
Reply With Quote
 
 
 
 
Bill Seurer
Guest
Posts: n/a
 
      04-06-2004
Todd wrote:

> I'm new to c++ and was wondering how to sort a 2 dimensional array. I'm
> using a select sort for 1 dimensional arrays but it is not working for a 2
> dimensional array. The 2 dimensional array are float elements. Thanks in
> advance


Why is "it not working"? It should work the same way but you just have
two sets of indices instead of one.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
To convert a one dimensional array into a two dimensional array using C amrutha0303 Software 0 08-03-2010 10:02 PM
Re: Sorting vectors (multi-dimensional array) jason.cipriani@gmail.com C++ 2 01-04-2009 10:12 AM
2 dimensional array - sorting mechanism Totti Javascript 1 11-02-2008 10:47 AM
How do copy Strings from a single dimensional array to double dimensional array Venkat C++ 4 12-05-2003 09:23 AM
Re: Two dimensional pointers and Two dimensional arrays Alf P. Steinbach C++ 0 08-18-2003 08:25 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57