Solved

Problem with multisort?

Posted on 2010-08-16
2
228 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
[X]
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
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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 look for a specific file type in a local or remote server directory using PHP.

691 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