dumb question?

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

    #1

    dumb question?

    I have a Collections.Gen eric.Dictionary (Of Integer, Integer). I want to sort
    its contents based on the keys.

    Right now the only way I can think of doing this is manually creating a
    KeyValuePair array from its contents, sorting it, and then clearing out the
    contents and adding them all back in order.

    Should I use SortedList instead? Or would that be worse for performance
    since it re-sorts on every item add?

    Paul


  • Bob Lehmann

    #2
    Re: dumb question?

    >> Should I use SortedList instead? Or would that be worse for performance
    since it re-sorts on every item add?

    What results did your perf testing produce when you compared them?

    Bob Lehmann


    "PJ6" <noone@nowhere. net> wrote in message
    news:u3VMjltcGH A.3840@TK2MSFTN GP04.phx.gbl...[color=blue]
    > I have a Collections.Gen eric.Dictionary (Of Integer, Integer). I want to[/color]
    sort[color=blue]
    > its contents based on the keys.
    >
    > Right now the only way I can think of doing this is manually creating a
    > KeyValuePair array from its contents, sorting it, and then clearing out[/color]
    the[color=blue]
    > contents and adding them all back in order.
    >
    > Should I use SortedList instead? Or would that be worse for performance
    > since it re-sorts on every item add?
    >
    > Paul
    >
    >[/color]


    Comment

    • Mattias Sjögren

      #3
      Re: dumb question?

      [color=blue]
      >I have a Collections.Gen eric.Dictionary (Of Integer, Integer). I want to sort
      >its contents based on the keys.[/color]

      Have you considered the SortedDictionar y(Of TKey, TValue) class?


      Mattias

      --
      Mattias Sjögren [C# MVP] mattias @ mvps.org
      http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
      Please reply only to the newsgroup.

      Comment

      • PJ6

        #4
        Re: dumb question?

        Fine I'll perf test

        "Bob Lehmann" <nospam@dontbot herme.zzz> wrote in message
        news:%23kjYuHvc GHA.1272@TK2MSF TNGP03.phx.gbl. ..[color=blue][color=green][color=darkred]
        >>> Should I use SortedList instead? Or would that be worse for performance[/color][/color]
        > since it re-sorts on every item add?
        >
        > What results did your perf testing produce when you compared them?
        >
        > Bob Lehmann
        >
        >
        > "PJ6" <noone@nowhere. net> wrote in message
        > news:u3VMjltcGH A.3840@TK2MSFTN GP04.phx.gbl...[color=green]
        >> I have a Collections.Gen eric.Dictionary (Of Integer, Integer). I want to[/color]
        > sort[color=green]
        >> its contents based on the keys.
        >>
        >> Right now the only way I can think of doing this is manually creating a
        >> KeyValuePair array from its contents, sorting it, and then clearing out[/color]
        > the[color=green]
        >> contents and adding them all back in order.
        >>
        >> Should I use SortedList instead? Or would that be worse for performance
        >> since it re-sorts on every item add?
        >>
        >> Paul
        >>
        >>[/color]
        >
        >[/color]


        Comment

        Working...