Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. List.Sort() Stability? Reliability...?

List.Sort() Stability? Reliability...?

Scheduled Pinned Locked Moved C#
algorithmstutorialquestion
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ely_bob
    wrote on last edited by
    #1

    I remember reading an article that said that List.Sort() was not necessarily reliable, but I cannot remember the context.. Does anyone know the reference or know of a sample (extra credit) that I can look at? I believe it was someones example of a "better" sorting algorithm... Thanks in advance.

    I'd blame it on the Brain farts.. But let's be honest, it really is more like a Methane factory between my ears some days then it is anything else...

    L P 2 Replies Last reply
    0
    • E ely_bob

      I remember reading an article that said that List.Sort() was not necessarily reliable, but I cannot remember the context.. Does anyone know the reference or know of a sample (extra credit) that I can look at? I believe it was someones example of a "better" sorting algorithm... Thanks in advance.

      I'd blame it on the Brain farts.. But let's be honest, it really is more like a Methane factory between my ears some days then it is anything else...

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      MSDN says List.Sort uses Array.Sort which is a QuickSort implementation. unreliable? if it does not sort correctly or in a finite time, it is not an algorithm and not worthy to be part of .NET unstable? correct (confirmed by http://en.wikipedia.org/wiki/Quicksort[^]). I hope you know what it means. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

      E R 2 Replies Last reply
      0
      • L Luc Pattyn

        MSDN says List.Sort uses Array.Sort which is a QuickSort implementation. unreliable? if it does not sort correctly or in a finite time, it is not an algorithm and not worthy to be part of .NET unstable? correct (confirmed by http://en.wikipedia.org/wiki/Quicksort[^]). I hope you know what it means. :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

        E Offline
        E Offline
        Ennis Ray Lynch Jr
        wrote on last edited by
        #3

        Learn something new every day. BTW, 10^6 seconds is a finite amount. O(n)=n^2 can be scary on large sets.

        Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me

        R 1 Reply Last reply
        0
        • E Ennis Ray Lynch Jr

          Learn something new every day. BTW, 10^6 seconds is a finite amount. O(n)=n^2 can be scary on large sets.

          Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me

          R Offline
          R Offline
          Richard Blythe
          wrote on last edited by
          #4

          Ennis Ray Lynch, Jr. wrote:

          Learn something new every day.

          Same here. I've used the List.Sort() method for years but I've never had any trouble with it. Maybe because I only use List<> for small collections only.

          The mind is like a parachute. It doesn’t work unless it’s open.

          1 Reply Last reply
          0
          • L Luc Pattyn

            MSDN says List.Sort uses Array.Sort which is a QuickSort implementation. unreliable? if it does not sort correctly or in a finite time, it is not an algorithm and not worthy to be part of .NET unstable? correct (confirmed by http://en.wikipedia.org/wiki/Quicksort[^]). I hope you know what it means. :)

            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

            Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

            R Offline
            R Offline
            Richard Blythe
            wrote on last edited by
            #5

            Do you have an alternative that you use?

            The mind is like a parachute. It doesn’t work unless it’s open.

            L 1 Reply Last reply
            0
            • R Richard Blythe

              Do you have an alternative that you use?

              The mind is like a parachute. It doesn’t work unless it’s open.

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              Most of the time I don't collect millions of objects, and I use the built-in Sort method. When it is really important, I apply special data structures and keep the "collection" sorted while building it up. Think of a list of lists, so items can be added to the right sub-list straight away. I trust others will suggest you keep huge amounts of data in a database and rely on its sorting capabilities. :)

              Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

              Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

              1 Reply Last reply
              0
              • E ely_bob

                I remember reading an article that said that List.Sort() was not necessarily reliable, but I cannot remember the context.. Does anyone know the reference or know of a sample (extra credit) that I can look at? I believe it was someones example of a "better" sorting algorithm... Thanks in advance.

                I'd blame it on the Brain farts.. But let's be honest, it really is more like a Methane factory between my ears some days then it is anything else...

                P Offline
                P Offline
                Pete OHanlon
                wrote on last edited by
                #7

                As you've been told, the sort method isn't really suitable on large data sets. It's important to understand that this is really the wrong place to apply sorting on large data sets - assuming it's coming from a database then the best way to do this is to retrieve the data already sorted and then fill the list.

                "WPF has many lovers. It's a veritable porn star!" - Josh Smith

                As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

                My blog | My articles | MoXAML PowerToys | Onyx

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups