473,383 Members | 1,815 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,383 software developers and data experts.

sorting 2D arrays by column

I am trying to sort a 2 dimensional array by column. I figured there would be a million tutorials/examples but can't find any that aren't specific to a situation or in JavaScript. POST SOME LINKS FOR ME! if you know of any.
Jun 10 '10 #1
4 3343
gits
5,390 Expert Mod 4TB
here is everything you would need for it ...
Jun 10 '10 #2
This is great for sorting 1D arrays, and it couuuld be helpful but what happens in a 2D array when I need to sort 1 column and need to bring the rest of the data for that row with me.
Jun 11 '10 #3
@bushnellweb
If i make a copy of the original column and sort it using array.sort() I can make a 2-D array called orderArray and it will hold in the [0] column the original position and in the [1] column it will hold the sorted arrays position where the values match. With this new orderArray I can move the other columns information to the same index as the one original column. good logic I hope...I'll let you know how it works and provide source code. I was hoping there was an algorithm to do this for me but apparently there isn't.
Jun 11 '10 #4
gits
5,390 Expert Mod 4TB
what do you exactly mean with a 2D array ... could you post how it looks like?
Jun 12 '10 #5

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

Similar topics

11
by: Alan Searle | last post by:
I have been trying to get an array to sort on a particular column and have been having problems with my main key ... array_multisort($dirlist, SORT_DESC, SORT_STRING); This function takes an...
1
by: Darryl Woodford | last post by:
Hi, I have an array of object Anag containing a string and a list of other strings (anagram dictionary). That is, some records in the array may only have two fields (anagram and the one word...
2
by: Jack Liddle | last post by:
Hi there I'm using Numerical Python to handle my arrays but I'm not sure how to accomplish the following. I want a NxNxNxN array where each element of the the array (A) is itself a 3x3 array....
4
by: Durand | last post by:
Hi all, I am using a sort method from Array class to order in ascending way. What can I do to descending way using same sort method? Thanks Durand
11
by: Paul Lautman | last post by:
I'm having some trouble understanding what is happening with some array sorting functions. In all cases, my compare function is: function compare($x, $y) { if ( $x == $y ) return 0; else if (...
2
by: zfareed | last post by:
I managed to sort a 2-dim array of lastnames but I am having trouble with printing the corresponding first names which are stored in a different 2-dim array. Here is my code for: ...
7
by: bkisa | last post by:
i m having problems with sorting arrays related to each others. i m reading the inputs from a file named input.txt and it is structured like 30 67 12 799 1 555 ... and its length i not defined...
7
by: aemado | last post by:
I am trying to write a program that reads in data from a user-specified file. I have to sort this file two ways, one using parallel arrays and the other using structs. I then have to output the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.