?
Solved

Problem with multisort?

Posted on 2010-08-16
2
Medium Priority
?
229 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 2000 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

Independent Software Vendors: 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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

762 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