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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:02:34+00:00 2026-05-22T18:02:34+00:00

I have an base array $base =array( A1 =array(); A2 =array(); A3 =array(); A4

  • 0

I have an base array

$base =array(
            "A1" =array();
            "A2" =array();
            "A3" =array();
            "A4" =array();
    );

and array of condition will use to sort

$condition  = array("A1" => "SORT_ASC",
                    "A4" => 'SORT_ASC',
                    "A3" => 'SORT_DESC'
                   );

I tried create a function like this to return a array_multi_sort

function sort_by_condition($condition) {


    return  array_multisort(
           $base['A1'], SORT_ASC, SORT_STRING,
           $base['A4'], SORT_ASC,SORT_NUMERIC, 
           $base['A3'], SORT_DESC,SORT_NUMERIC,
           $base['A2'],//default
           );

}

But I dont know how can I return something like this?

  • 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-22T18:02:35+00:00Added an answer on May 22, 2026 at 6:02 pm

    You may need to give the proper array keys to array multisort:

    $ar = array(
           array("10", 11, 100, 100, "a"),
           array(   1,  2, "2",   3,   1)
          );
    
    array_multisort($ar[0], SORT_ASC, SORT_STRING,
                    $ar[1], SORT_NUMERIC, SORT_DESC);
    

    This is from the manual but I assume your example would become more like this:

     array_multisort( $base['A1'], SORT_ASC, SORT_STRING,
                      $base['A2'], SORT_ASC, SORT_NUMERIC, 
                      etc...
                    );
    

    I realize you have probably read it a few times but see the examples in the manual and try making it work outside the function first. Good-luck! 🙂

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

Sidebar

Related Questions

I have a multi-dimensional array that looks like this: The base array is indexed
Basically, I have an array like this: val base_length = Array( 0, 1, 2,
If I have something like this: class Post < ActiveRecord::Base has_many :comments, :as =>
I have base 64 encoded string that looks something like this. cuVrcYvlqYze3OZ8Y5tSqQY205mcquu0GsHkgXe4bPg= I have
I have a base class object array into which I have typecasted many different
I have an array of pointers to a base class, so that I can
I have a base class with an optional virtual function class Base { virtual
I have a base 'node' class with an 'update()' member function now i have
How to compare the similarity between two arrays? Say I have: Base Array: [.5,0,0,0,.25,0,0,.25,0,0,0,0]
I have a base User form that I am subclassing for each use case,

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.