Well unregged, you might have better luck using an STL list rather than a plain single link list.
.sort() will automatically and quickly sort your list, provided operator< is defined for whatever data type the list is of.
.reverse() will turn it around
.copy() will dump the list into another iterator.
.copy()'ing to ostream_iterator<WHATEVER_YOUR_TYPE_IS>(cout, "\n") will output it. You can change the \n to any delimiter you want.
Load this, c/l/r it, then see if you can adapt it to your problem:
Code:
#include <iostream>
#include <list>
#include <string>
int main () {
list<string>f;
f.push_back("Tarp");
f.push_back("Yellow");
f.push_back("Alpha");
f.push_back("Doggie");
f.push_back("Markers");
f.push_back("Bush");
copy(f.begin(), f.end(), ostream_iterator<string>(cout, "\n"));
f.sort();
cout << '\n';
copy(f.begin(), f.end(), ostream_iterator<string>(cout, "\n"));
f.reverse();
cout << '\n';
copy(f.begin(), f.end(), ostream_iterator<string>(cout, "\n"));
return 0;
}
Enjoy