Sort problem :(

I have struct like this...User write price and name and each element...
First i make new float array and in this array i put unsorted prieces from linked list.
And then i use merge sort for sorting this array by price...
With for loop i check if first sorted price in array == list->price...
If this is equal then i print list-pric[this pleace]e and list->name[this pleace].

My problem is, when i use 2 equal prices program prints data from struct only for this first pleace.

How can i write code that i skip this check again?



struct lista{
float price[10000];
char name[10000][20];
int cursor;
};

I have struct like this...User write price and name and each element...
Wow, that's some massive record.

First i make new float array and in this array i put unsorted prieces from linked list.
And then i use merge sort for sorting this array by price...
That must be tricky. How do you keep the names and prices in sync.

My problem is, when i use 2 equal prices program prints data from struct only for this first pleace.
It's impossible to tell what you've done wrong (or really what you mean) without seeing your code.

Have you considered breaking it up as in:
1
2
3
4
5
6
7
8
9
10
11
12
13
struct Item
{
    float price;
    std::string name;
};

typedef std::vector<Item> Items;

struct lista  // if you still think you need this thing
{
    Items items;
    int cursor;
};
Last edited on
Topic archived. No new replies allowed.