Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6648605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:40:31+00:00 2026-05-26T00:40:31+00:00

Possible Duplicate: Sorting an associative array in PHP I have an array that looks

  • 0

Possible Duplicate:
Sorting an associative array in PHP

I have an array that looks like the below one. I need to order it by the points values Highest to lowest. I have tried all the sorting functions and some bring back crazy results.

(
  [0] => Array
  (
    [name] => Shane Jones
    [points] => 43
  )
  [1] => Array
  (
    [name] => Katie 'Kitty' Youd
    [points] => 50
  )
  [2] => Array
  (
    [name] => Steve Bennett
    [points] => 50
  )
  [3] => Array
  (
    [name] => Sharon Harvey
    [points] => 99
  )
  [4] => Array
  (
    [name] => Sean Dentith
    [points] => 50
  )

)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:40:32+00:00Added an answer on May 26, 2026 at 12:40 am

    See Example #3 in the PHP Manual entry for array_multisort

    <?php
    $data[] = array('volume' => 67, 'edition' => 2);
    $data[] = array('volume' => 86, 'edition' => 1);
    $data[] = array('volume' => 85, 'edition' => 6);
    $data[] = array('volume' => 98, 'edition' => 2);
    $data[] = array('volume' => 86, 'edition' => 6);
    $data[] = array('volume' => 67, 'edition' => 7);
    
    // Obtain a list of columns
    foreach ($data as $key => $row) {
        $volume[$key]  = $row['volume'];
        $edition[$key] = $row['edition'];
    }
    
    // Sort the data with volume descending, edition ascending
    // Add $data as the last parameter, to sort by the common key
    array_multisort($volume, SORT_DESC, $edition, SORT_ASC, $data);
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Sorting an associative array in PHP Hello all, I have an array
Possible Duplicate: Sorting an associative array in PHP How to sort a multidimensional array
Possible Duplicate: Sorting a multidimensional array? I have an a multi dimesional associative array:
Possible Duplicate: sorting in nsmutable array I have 2 NSMutableArray array. I have to
Possible Duplicate: Sorting a multidimensional array in PHP? $songs = array( '1' => array('artist'=>'The
Possible Duplicate: Sorting multidimensional array in PHP How can I sort by key in
Possible Duplicate: Sorting by Name (alphabetic) Say I have the code below. I have
Possible Duplicate: Ignoring 'A' and 'The' when sorting with XSLT I have a list
Possible Duplicate: Interview Q: sorting an almost sorted array (elements misplaced by no more
Possible Duplicate: NAnt or MSBuild, which one to choose and when? What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.