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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:29:34+00:00 2026-05-12T12:29:34+00:00

Say,$arr contains multiple sub-arrays with the key pos, $arr = sortByKey($arr,’pos’); After that the

  • 0

Say,$arr contains multiple sub-arrays with the key “pos”,

$arr = sortByKey($arr,'pos');

After that the sub-array with smallest “pos” value will be ordered first,and so on.

EDIT

$sub1 = array('pos' => 2);
$sub2 = array('pos' => 1);
$arr = array($sub1,$sub2);
$arr = sortByKey($arr,'pos');

After this function,$arr will be array($sub2,$sub1)

  • 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-12T12:29:34+00:00Added an answer on May 12, 2026 at 12:29 pm

    see the ksort function.

    here come the manual of the function.

    sorry also I think you are ccase you are more looking into uasort you would be able to define a function to compare each of your elements and sort them

    // Array to be sorted
    
    print_r($array);
    
    // Sort and print the resulting array
    uasort($array, create_function('$a,$b', 'return $a[\'pos\'] == $b[\'pos\'] ? 0 : (($a[\'pos\'] < $b[\'pos\']) ? -1 : 1);'));
    print_r($array);
    

    have to be tested not sure about the double ? operator …

    Cheer

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

Sidebar

Related Questions

Suppose we have an array say: int arr[1000]; and I have a function that
Let's say I have array of bytes: byte[] arr = new byte[] { 0,
Let's say I have a 10 element array: from ctypes import * arr =
Say I have an array of integers: arr = [0,5,7,8,11,16] and I have another
Lets say I have an array like int arr[10][10]; Now i want to initialize
I have an array int arr[5] that is passed to a function fillarr(int arr[])
Say a shared library contains the following lines: const char* const arr[] = {
Say, I have a file that contains 100000 integers. Each integer is on a
Let's say I have the following array: arr = [, 2121, 8, myString] I
I have an array of values say arr(0)=Sam arr(1)=1452 arr(2)=NY I want to generate

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.