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 5932853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:53:32+00:00 2026-05-22T14:53:32+00:00

How do I sort array that has highest point from 15.00 key? I have

  • 0

How do I sort array that has highest point from 15.00 key?

I have an array look like this:

Array
(

    [9] => Array
        (
            [15.00] => 3.0
            [20.00] => 8.0
            [25.00] => 10.5
        )

    [2] => Array
        (
            [15.00] => 2.0
            [20.00] => 5.0
            [25.00] => 2.5
        )


    [4] => Array
        (
            [15.00] => 6.0
            [25.00] => 4.0
            [30.00] => 6.0
        )
)

In order it should be: 4, 9 and 2

  • 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-22T14:53:33+00:00Added an answer on May 22, 2026 at 2:53 pm

    PHP has usort, a function enabling you to sort via a user-provided comparison function. There’s also uasort that maintains index association.

    Here’s an example:

    <?php
    $array = Array(
      9 => Array(
                15.00 => 3.0,
                20.00 => 8.0,
                25.00 => 10.5
      ),
      2 => Array(
                15.00 => 2.0,
                20.00 => 5.0,
                25.00 => 2.5
      ),
      4 => Array(
                15.00 => 6.0,
                25.00 => 4.0,
                30.00 => 6.0
      )
    );
    
    function my_func($a, $b) {
       if ($a[15.00] == $b[15.00])
          return 0;
       return ($a[15.00] < $b[15.00]) ? 1 : -1; // backwards sorting
    }
    
    uasort($array, my_func);
    var_dump($array);
    ?>
    

    And here’s it working.

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to sort an array that can look like this: $array[4][0] = array('id'
I have an array that I would like to sort using a date field
I have a multi-dimensional array that looks like this: The base array is indexed
I have an array of filenames and need to sort that array by the
I have an array that I want to sort based on the value of
How do you sort an array of strings in C++ that will make this
The .Net framework has an Array.Sort overload that allows one to specify the starting
I have a list-generic that has a property (class type). I need a sort
I have an array of an object type that has different text fields to
I have a 2D array that holds unique integers - this represents a physical

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.