Need Help with SORT ing

#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <iomanip>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
int pos;
int a;
string * country = new string [10];
string * xchange = new string [10];
float * difference= new float[10];

string line;
fstream Currencyfile;
Currencyfile.open("currency.txt");
while(getline(Currencyfile,line))
{
if(line == "")
{
break;
}
pos = line.find(":",0);

if(pos!=line.npos)
{
char * b = new char(line.size()+1);
strcpy(b,line.c_str());

country[a] = strtok(b , ":");
xchange[a] = strtok(NULL , ":");
difference[a] = atof(strtok(NULL, ":"));
a++;
}
}
Currencyfile.close();
}

The above is my code and below is the content in the .txt with the information that i wanted to sort in ascending order for the last column . Please advice me on what i should do into other to sort it correctly . Thank you who ever that reply in advance .

USD to SGD:1.2846:+0.0087
EUR to SGD:1.7473:+0.0076
GBP to SGD:2.0090:+0.0113
SGD to JPY:59.633:-0.4810
SGD to HKD:6.0564:-0.0434
SGD to MYR:2.4459:-0.0040
SGD to IDR:6,937.:-32.000
SGD to CNY:4.9626:-0.0143
AUD to SGD:1.2773:+0.0024
Just a hint, you can pass the last column and row# to map<string, int> or multimap<string, int>, then it's sorted automatically, then you need to find a method for the rest work.
Topic archived. No new replies allowed.