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. Sorting?

Sorting?

Scheduled Pinned Locked Moved C#
questionalgorithmsdata-structurestutorial
3 Posts 3 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.
  • B Offline
    B Offline
    bug_aonz
    wrote on last edited by
    #1

    I used Array.Sort to sort my string array.For example string[] ss=new string[]{ AA,aA,aa,Aa,BB,Ba } Array.Sort(ss); Now the result of ss is AA Aa BB Ba aA aa but i need it sort likes dictionary. aa aA Aa AA Ba BB How can i do this ? thank=)

    L M 2 Replies Last reply
    0
    • B bug_aonz

      I used Array.Sort to sort my string array.For example string[] ss=new string[]{ AA,aA,aa,Aa,BB,Ba } Array.Sort(ss); Now the result of ss is AA Aa BB Ba aA aa but i need it sort likes dictionary. aa aA Aa AA Ba BB How can i do this ? thank=)

      L Offline
      L Offline
      lmoelleb
      wrote on last edited by
      #2

      Basically .NET tries to follow the sorting rules of the current culture, so the first thing to do is to make sure the sorting is done wit hthe correct cultures. If you are still not happy with the way it is done, you can provide your own comparison rules to the sorting methods.

      1 Reply Last reply
      0
      • B bug_aonz

        I used Array.Sort to sort my string array.For example string[] ss=new string[]{ AA,aA,aa,Aa,BB,Ba } Array.Sort(ss); Now the result of ss is AA Aa BB Ba aA aa but i need it sort likes dictionary. aa aA Aa AA Ba BB How can i do this ? thank=)

        M Offline
        M Offline
        Mandaar Kulkarni
        wrote on last edited by
        #3

        The default sorting is based on the ascii values where you are getting 'BB ' entry before 'aA'. In your case you will have to write your own way of sorting the array.

        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