Can you sort a deque collection without using any functions?

Without using sort() or swap(), how can I sort the deque?
I did the usual swapping code one and it did not work... Does it only works on array based list?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  for (int i = 0; i < email.size(); i++) 
  {
    for (int j = i + 1; j < email.size(); j++) 
    { 
      if (email[i].email > email[i].email) 
      { 
        string temp = email[i].email; 
        email[i].email = email[j].email;   
        email[j].email = temp; 
      } // if 
    } // for 
  } // for 
  for (int l = 0; l < email.size(); l = l + 1)
  {
    cout << email[l].email << endl;
  }
Look carefully at what you're comparing on line 5.
silly me, all because of a typo
Last edited on
Topic archived. No new replies allowed.