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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:34:25+00:00 2026-06-10T17:34:25+00:00

Hi I am actually trying to sort an array at third level with different

  • 0

Hi I am actually trying to sort an array at third level with different keys.

The below is Sample array input.

Array
(
    [19067] => Array
        (
            [Morrisville, PA] => 5.02
        )

    [18977] => Array
        (
            [Washington Crossing, PA] => 6.63
        )

    [08695] => Array
        (
            [Trenton, NJ] => 2.84
        )

    [08690] => Array
        (
            [Trenton, NJ] => 1
        )

    [08666] => Array
        (
            [Trenton, NJ] => 2.84
        )

    [08650] => Array
        (
            [Trenton, NJ] => 0
        )

    [08648] => Array
        (
            [Lawrence Township, NJ] => 2.88
        )

    [08647] => Array
        (
            [Trenton, NJ] => 2.84
        )

    [08646] => Array
        (
            [Trenton, NJ] => 2
        )

)

Can any body help me to sort the above array at third level

Expected result should like:

Output:

Array
(
    [08650] => Array
        (
            [Trenton, NJ] => 0
        )

    [08690] => Array
        (
            [Trenton, NJ] => 1
        )   

     [08646] => Array
        (
            [Trenton, NJ] => 2
        )

    [08666] => Array
        (
            [Trenton, NJ] => 2.84
        )   

    [08695] => Array
        (
            [Trenton, NJ] => 2.84
        )

    [08647] => Array
        (
            [Trenton, NJ] => 2.84
        )

    [08648] => Array
        (
            [Lawrence Township, NJ] => 2.88
        )

    [19067] => Array
        (
            [Morrisville, PA] => 5.02
        )

    [18977] => Array
        (
            [Washington Crossing, PA] => 6.63
        )   


)

Thanks in advance..

  • 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-06-10T17:34:27+00:00Added an answer on June 10, 2026 at 5:34 pm
    uasort($array, function (array $a, array $b) {
        return current($a) - current($b);
    });
    

    Do note the comments: values which differ less than 1.0 will be sorted as the same. You may want to do (current($a) - current($b)) * 100 or otherwise round the value, depending on what value ranges you expect.

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

Sidebar

Related Questions

I'm trying to write a code to actually sort my array in an ascending
I'm trying to sort an array of NSStrings but i'm unsure how to actually
I am trying to sort array/lists/whatever of data based upon the unicode string values
I am trying to implement some sort of MVC in Java. Actually it's more
I am actually trying to solve a problem where I have an array which
What I'm actually trying to do is put a WebKitView into a ScreenSaver (which
I am actually trying to change the color index for the first word with
I'm actually trying to fix this issue where my projects are always out of
is there similar syntax to php's $$variable in python? what I am actually trying
I am new to android..Actually iam trying to increase the RAM Memory of android

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.