Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Problem with multisort?

Posted on 2010-08-16
2
226 Views
Last Modified: 2013-12-13
I am trying to sort a multidimensional array of strings  with a variable number of columns.

I concatenate the columns and place them in the array at a fixed column position.
When I try to sort with array_multisort, using this column, I get the error:

Warning: array_multisort() [function.array-multisort]: Argument #2 is expected to be an array or a sort flag


for ( $i = 0 ; $i < count($set) ; $i++ )
        {
                $blob="";

                        for ( $j = 0 ; $j < count($set[$i]) ; $j++ )
                            {
                                      
                                       $blob=$blob . $set[$i][$j]["tindex"];
                                      
                            }
                            $set[$i][100]["tindex"]=$blob;


array_multisort($set,$set[0][100]["tindex"]);

Open in new window

0
Comment
Question by:pillmill
2 Comments
 
LVL 26

Expert Comment

by:arober11
ID: 33451567
0
 
LVL 1

Accepted Solution

by:
martimarkov earned 500 total points
ID: 33454128
Try this co to see if it is working:
array_multisort($set, SORT_ASC, $set[0][100]["tindex"], SORT_DESC);

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question