Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

doubt about sorting

Posted on 2004-03-26
3
Medium Priority
?
237 Views
Last Modified: 2010-04-01
I have input file with following contents

abc,1111ab@1111bb@1111aa
xyz,2222dd@2222dc@2222da@2222tt

first field is city & second is list of pocos.In first line there r 3 pocos & in second line 4 pocos there can be n no.of pocos.I want to sort the pocos.How to it in c++?


Can anyone help me?
0
Comment
Question by:girija_cv
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 12

Expert Comment

by:stefan73
ID: 10685259
Hi girija_cv,
Please clarify which sort order you want. All pocos (?) together, by city as primary sort key, or what?

Cheers,

Stefan
0
 

Author Comment

by:girija_cv
ID: 10685447
only poco sort
0
 
LVL 39

Accepted Solution

by:
itsmeandnobodyelse earned 80 total points
ID: 10685534
     string line = "abc,1111ff@1111xx@1111ss@1111as";
      string city;
      list<string> poco_list;
      istringstream ssLine (line);
        getline(ssLine, city, ',');
      while (!ssLine.eof())
      {
          string poco;
            getline(ssLine, poco, '@');
          if (poco.empty())
              break;
          poco_list.push_back(poco);
      }
      poco_list.sort();
      for (list<string>::iterator it = poco_list.begin(); it != poco_list.end(); ++it)
          cout << *it << '@';
      cout << endl << endl;

Hope, that helps
Alex
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question