Solved

Problem with multisort?

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now