CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2001
    Location
    ROMANIA
    Posts
    30

    sorting algorythm that keeps the order of equal elements

    hello !

    i need to find an algorythm for sorting that keeps the order of equal elements...

    all that i've tried are messing up my data...

    also, maybe that algorythm has a form in witch i can implement a time routine to see how much time remains until full sorting...

    maybe someone known such as algorythm...

    thanks !

    PS : excuse my english...

  2. #2
    Join Date
    Aug 2001
    Location
    Stockholm, Sweden
    Posts
    1,664
    I'm not fully sure I understand you... but maybe you want a so called stable sorting algorithm, such as radix sort.

    Search on www.google.com for more info about it.

  3. #3
    Join Date
    Apr 1999
    Location
    Altrincham, England
    Posts
    4,470
    In C++, use std::stable_sort()
    Correct is better than fast. Simple is better than complex. Clear is better than cute. Safe is better than insecure.
    --
    Sutter and Alexandrescu, C++ Coding Standards

    Programs must be written for people to read, and only incidentally for machines to execute.

    --
    Harold Abelson and Gerald Jay Sussman

    The cheapest, fastest and most reliable components of a computer system are those that aren't there.
    -- Gordon Bell


  4. #4
    Join Date
    Aug 2002
    Location
    Madrid
    Posts
    4,588
    The STL comes indeed with stable_sort, which is most probably implemented in terms of a merge sort. The run-time characteristics of this sorting method are pretty predictable, so you should be able to modify it so that it gives a sort of progress-report. Other sorting algorithms, like quicksort or introsort (the std::sort algorithm) are not that predictable.
    Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
    Supports C++ and VB out of the box, but can be configured for other languages.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured