Thread: Sorting words with a fast, effincient sorting method

  1. #16
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    Look at the C standard qsort function. You don't need to write a sort algorithm yourself. qsort will sort anything, even horrible string classes.

  2. #17
    TK
    Guest
    #include<algorithm>

    vector<string> vec_name;
    string x;

    //get input from user for example
    while (cin >> x)
    vec_name.push_back(x);

    sort(vec_name.begin(), vec_name.end() );

    The speed is nlog(n)

    It might not work in MSVC++6 because that compiler doesn't meet the C++ standard.

  3. #18
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    apstring isn't that bad. It provides the subset of the most useful functions in std::string.
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

  4. #19
    Unregistered
    Guest
    I nominate bogo-sort definition as most humorous post. Well done!!!

  5. #20
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >I nominate bogo-sort definition as most humorous post.
    If you stick around long enough you could probably build a library of theories for quantum bogodynamics simply by reading some of the code posted on these boards.

    [anticipation]
    quantum bogodynamics /kwon'tm boh`goh-di:-nam'iks/ n.

    A theory that characterizes the universe in terms of bogon sources (such as politicians, used-car salesmen, TV evangelists, and suits in general), bogon sinks (such as taxpayers and computers), and bogosity potential fields. Bogon absorption, of course, causes human beings to behave mindlessly and machines to fail (and may also cause both to emit secondary bogons); however, the precise mechanics of the bogon-computron interaction are not yet understood and remain to be elucidated. Quantum bogodynamics is most often invoked to explain the sharp increase in hardware and software failures in the presence of suits; the latter emit bogons, which the former absorb. See bogon, computron, suit, psyton.
    [/anticipation]


    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginners Contest #2 For those who wanted more!!
    By ILoveVectors in forum Contests Board
    Replies: 16
    Last Post: 08-12-2005, 12:03 AM
  2. sorting words
    By owi_just in forum C Programming
    Replies: 5
    Last Post: 05-27-2005, 06:31 PM
  3. Problem with malloc() and sorting words from text file
    By goron350 in forum C Programming
    Replies: 11
    Last Post: 11-30-2004, 10:01 AM
  4. New Theme
    By XSquared in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 04-01-2004, 08:00 PM