468,458 Members | 1,745 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,458 developers. It's quick & easy.

Creating a list of multiple element rows, and sorting them.

Daz
Hi everyone.

I am trying to make a program which handles about 70 different objects,
of the same type. The properties are as follows:

std::string ItemName
int ItemType
int Calories
int Weight
int Density

I am looking for a way of sorting the list during the several stages of
their handling.processing, but I don't have a clue where to start. The
list will need to be sorted 3 times, once by Calories, once by Weight,
and then again by Density.

Obviously, I can put each property into a vector, and then sort them,
but this doesn't sort the others into their respective positions (they
need to be handled as rows of data). I am sure that I am either not
realizing the full potential of a vector, or I need to use/create
something else, such as a custom class based on a vector, but I am
really not sure.

I would appreciate any suggestions.

Thanks in advance.

Daz

Jul 2 '06 #1
2 1550
Daz wrote:
Hi everyone.

I am trying to make a program which handles about 70 different objects,
of the same type. The properties are as follows:

std::string ItemName
int ItemType
int Calories
int Weight
int Density

I am looking for a way of sorting the list during the several stages of
their handling.processing, but I don't have a clue where to start. The
list will need to be sorted 3 times, once by Calories, once by Weight,
and then again by Density.
For a small data set like this, you might as well use 3 maps
(std::map<int,Object*>), and you your three sort criteria as the keys.

--
Ian Collins.
Jul 2 '06 #2
Daz

Ian Collins wrote:
For a small data set like this, you might as well use 3 maps
(std::map<int,Object*>), and you your three sort criteria as the keys.

--
Ian Collins
Thanks Ian! I will look into that. :)

Jul 2 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Craig Banks | last post: by
6 posts views Thread by Adam Tilghman | last post: by
10 posts views Thread by moondaddy | last post: by
1 post views Thread by Alan_C | last post: by
reply views Thread by =?Utf-8?B?U3RldmU=?= | last post: by
6 posts views Thread by dufnobles via AccessMonster.com | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kmladenovski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.