Fast sort

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Boni

    #1

    Fast sort

    Dear all,
    what is the best collection for fast sort of small (about 100) data rows.I
    want to use collection's sort algorithm, instead of implementing my own.
    Thanks,
    Boni


  • Michael C#

    #2
    Re: Fast sort

    Check out SortedList

    "Boni" <oilia@nospam > wrote in message
    news:e54HFl%23u FHA.740@TK2MSFT NGP10.phx.gbl.. .[color=blue]
    > Dear all,
    > what is the best collection for fast sort of small (about 100) data rows.I
    > want to use collection's sort algorithm, instead of implementing my own.
    > Thanks,
    > Boni
    >[/color]


    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: Fast sort

      "Boni" <oilia@nospam > schrieb:[color=blue]
      > what is the best collection for fast sort of small (about 100) data rows.I
      > want to use collection's sort algorithm, instead of implementing my own.[/color]

      'ArrayList.Sort ' and 'Array.Sort' are implemented as a quick-sort algorithm,
      which is pretty fast for most cases (Theta(n log(n)) for n items).

      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://classicvb.org/petition/>

      Comment

      • Michael C#

        #4
        Re: Fast sort

        Keep in mind though that QuickSort is pretty slow for a collection of items
        that are pre-sorted, or nearly sorted, beforehand - worst case O(n ^ 2)
        instead of the best case O(n lg n) that Herfried pointed out. With only 100
        items it probably won't make a noticeable difference anyway, but keep that
        in mind if you add more items to your collection; or if you perform this
        sort a bunch of times.

        "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
        news:ufeKK8DvFH A.2924@TK2MSFTN GP15.phx.gbl...[color=blue]
        > "Boni" <oilia@nospam > schrieb:[color=green]
        >> what is the best collection for fast sort of small (about 100) data
        >> rows.I want to use collection's sort algorithm, instead of implementing
        >> my own.[/color]
        >
        > 'ArrayList.Sort ' and 'Array.Sort' are implemented as a quick-sort
        > algorithm, which is pretty fast for most cases (Theta(n log(n)) for n
        > items).
        >
        > --
        > M S Herfried K. Wagner
        > M V P <URL:http://dotnet.mvps.org/>
        > V B <URL:http://classicvb.org/petition/>[/color]


        Comment

        Working...