473,395 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to sort an array columnwise?

Hi, i have an array which contain object name and weight.
Expand|Select|Wrap|Line Numbers
  1.  NonLiv2 = [
  2.                 ["bottle", 2],
  3.                 ["Book", 2],
  4.                 ["iron", 2],
  5.                 ["Lock", 2],
  6.                 ["cup", 2],
  7.                 ["phone", 2],
  8.                 ["camera", 2],
  9.                 ["toothpaste", 2]
  10.                 ];
Now i want to sort the array based on their weight.
Dec 1 '11 #1
2 1946
gits
5,390 Expert Mod 4TB
have a look at the array sort method ... and post what you have tried.

regards
Dec 1 '11 #2
johny10151981
1,059 1GB
take a look at for in
for(key in var)
It would give you a way
Dec 2 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Boefje | last post by:
Hi, What I want is simple, but I can't figure it out at the moment. Let's say this is an array names $matches: Array ( => Array (
19
by: David | last post by:
Hi all, A while back I asked how to sort an array of strings which would have numerals and I wanted to put them in sequential numerical order. For example: myArray = "file1"; myArray =...
6
by: Tamir Khason | last post by:
Let's say I have Point and I want to sort it circle way (e.g. 2;2.4;1,8;2,8,5;4;8,2;7,1;4 The algo for this is: if ((p.X<p.X & p.Y<Avg(p).Y & p.Y<Avg(p).Y) | (p.X>p.X & p.Y>Avg(p).Y &...
21
by: yeti349 | last post by:
Hi, I'm using the following code to retrieve data from an xml file and populate a javascript array. The data is then displayed in html table form. I would like to then be able to sort by each...
4
by: christiang | last post by:
Hi guys I'd like to sort a multidimensional array that hasn't numerical index, in fact it is like: Array ( => Array ( => mobile => 1 )
1
by: millw0rm | last post by:
i got 2 array one holds the actual data n another is user generated sort order... how to sort array #1 according to array #2???? array shld be sorted according to sortorder Array #1 ( =Array...
4
by: Santosh Nayak | last post by:
Hi, Is it possible to sort the array of struct based on the data members. e.g. struct { int a ; float b ; char c ; } TEMP ;
5
by: tienlx | last post by:
Hi all, I want to sort an array of struct _line: .... typedef struct _line { int x1; int x2; } line;
4
by: Kovu | last post by:
Hi, I have the next problem. I want to sort the array for the key, using a function. I have been looking for a function to operate with arrays, but I haven't found anything. Ej: Array ( ...
7
by: JWest46088 | last post by:
I am trying to write a program based off of a flowchart. The program is supposed to sort an array. I am having trouble getting it to sort though. I know it has something to do with my code, but I...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.