Solved

Problem with multisort?

Posted on 2010-08-16
2
227 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

Technology Partners: 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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

733 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