473,406 Members | 2,259 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Sorting a 2 dimensional array

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
Jul 22 '05 #1
4 8147

"Todd" <fthdg> wrote in message news:10*************@corp.supernews.com...
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
Jul 22 '05 #2

"Todd" <fthdg> wrote in message news:10*************@corp.supernews.com...
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
Jul 22 '05 #3
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.
Jul 22 '05 #4
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.
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Paul Kirby | last post by:
Hello All I am trying to update me code to use arrays to store a group of information and I have come up with a problem sorting the multiple array :( Array trying to sort: (7 arrays put into...
2
by: D. Roshani | last post by:
Hello ! I wonder if any one can help me to create a cosomize sorting order (as Macro or added small program in c++ or c# which does this work) in a Access Database contaning one table only words...
4
by: Todd | last post by:
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...
7
by: Karin Jensen | last post by:
Hi I am running a PHP program that connects to an Access 2000 database via ODBC: $results = odbc_exec($connection_id, $sql_select); Is it possible to sort the contents of $results? I wish to...
7
by: Foodbank | last post by:
Hi everyone. I'm having trouble with this radix sorting program. I've gotten some of it coded except for the actual sorting :( The book I'm teaching myself with (Data Structures Using C and...
10
by: Roy Gourgi | last post by:
Hi, How would I sort an array? TIA Roy
0
by: Sick | last post by:
Hey, The Array.Sort function only applies to one-dimension arrays. Is there a solution for sorting a two-dimensional array, preferably *without* the usage of additional controls such as...
5
by: JC | last post by:
Hi all, I have scoured the internet for articles on sorting multi-dimensional arrays of generic types e.g. T using the IComparer<Tinterface and have run into a real roadblack. There does not...
1
by: Totti | last post by:
Hi everyone, I am a newbie to javascript learning it for 2 months now, i am trying to make a sorter who will read english words from the one textbox or datafile and store them in a 2 dimensional...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.