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

  • SEARCH
  • Home
  • 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 9066769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:47:39+00:00 2026-06-16T16:47:39+00:00

Like the title sais I have no idea where to start and using asort()

  • 0

Like the title sais I have no idea where to start and using asort() and sort() are not helping in the way I thought it would. Essentially I have an array as such:

$array = array(
    'array_c' => array(
        'array_b' => (
            array('object' => 'e some Object'),
            array('object' => 'b some Object'),
        ),
        'array_a' => (
            array('object' => 'awesome Object'),
        ),
    ),
    'array_a' => array(
        'array_e' => (
            array('object' => 'e some Object'),
        ),
        'array_a' => (
            array('object' => 'b awesome Object'),
        );
    );
);

So I was looking at asort as I want to keep the associations the same, The function I have started writing is:

function sort_me(some_array){
    $new_array = asort(some_array);
    return $new_array;
}

this function then takes in $array[‘array_c’] so that you get back an alphabetically sorted array that looks like:

    'array_c' => array(
        'array_a' => (
            array('object' => 'awesome Object'),
        ),
        'array_b' => (
            array('object' => 'b some Object'),
            array('object' => 'e some Object'),
        ),

    ),

can some one tell me why my function is not working? Am I misunderstanding the power of asort?

  • 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-16T16:47:40+00:00Added an answer on June 16, 2026 at 4:47 pm

    ksort is the way to go, but ksort does not return a newly sorted array:

    http://us.php.net/ksort

    it returns a bool -> true if the array could be sorted, otherwise false…

    this code snipped should do what you need:

    ksort($array);
    foreach($array as $key=>$value){
        ksort(value);
        $array[$key]=$value;
    }
    print_r($array);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello all i have one json object like {event1:{title:My birthday,start:12\/27\/2011 10:20 ,end:12\/27\/2011 00:00 },event2:{title:My
I have a text like: Title A some description on a few lines, there
Like the title says, I need a way to detect if the build is
I've problem like in title. I'm using ruby with Sinatra framework and trying to
so basically like the title says is there a way to use NSSortDescriptor to
I would like to create a table which has column like title,target and I
Say I have a JSON string like: {title:aaa,url:bbb,image:{url:ccc,width:100,height:200}, ... My accessor: import com.google.gson.annotations.SerializedName; public
I have a table lists containing list information like title and id (auto_increment) and
I use a form where i have listed the data from database like title,
I have an array filled with dictionaries. Each dictionary have strings like title, info

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.