Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

php array - how to insert preserving the sorting order ?

Posted on 2011-05-11
2
Medium Priority
?
255 Views
Last Modified: 2012-05-11
I have an array of ISBNS which I would like to be sorted
when I put a  new ISBN, how to insert it to preserve a sorting order
0
Comment
Question by:Rozamunda
2 Comments
 
LVL 15

Accepted Solution

by:
Jagadishwor Dulal earned 1000 total points
ID: 35743790
How do you want to sort array?  By key or by elements
First add array
$newval = array (2331, 232322,3434343);
array_push ($newval ,312126);  // we are adding four more elements to the array 

Open in new window

Now Choose your sorting option:
asort(); //elements sort ascending
arsort(); //elements sort descending;
ksort();//by  key sort ascending;
krsort(); //by key sort descending;

Open in new window

0
 
LVL 1

Expert Comment

by:phutsa
ID: 35743834
Thank you. This is also my problem. It's easy for understanding.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
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…
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.
Suggested Courses

564 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