How to sort an array columnwise?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ravi Godara
    New Member
    • Dec 2011
    • 1

    #1

    How to sort an array columnwise?

    Hi, i have an array which contain object name and weight.
    Code:
     NonLiv2 = [
                    ["bottle", 2],
                    ["Book", 2],
                    ["iron", 2],
                    ["Lock", 2],
                    ["cup", 2],
                    ["phone", 2],
                    ["camera", 2],
                    ["toothpaste", 2]
                    ];
    Now i want to sort the array based on their weight.
    Last edited by Dormilich; Dec 1 '11, 08:48 AM.
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    have a look at the array sort method ... and post what you have tried.

    regards

    Comment

    • johny10151981
      Top Contributor
      • Jan 2010
      • 1059

      #3
      take a look at for in
      for(key in var)
      It would give you a way

      Comment

      Working...