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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:02:13+00:00 2026-06-16T20:02:13+00:00

I am having one array like this, array[0][0],[1][0],[2][0] are questions and array[0][1],[1][1],[2][1] are the

  • 0

I am having one array like this,

array[0][0],[1][0],[2][0] are questions and array[0][1],[1][1],[2][1] are the answers to that questions.
Now i want to sort this array with respect to number of answers.
1st Ques having only one answer and
2nd having two answer and 3rd having three answer.
The sorted array should be in descending order with respect to number of answers to that question.
Is there anyway to achieve this in sql? Or how Can we sort in php? Hope my question is clear. Thank you in advance.

Array
(
    [0] => Array
        (
            [0] => Array
                (
                    [0] => 12
                    [1] => 110
                    [2] => Tom
                    [3] => Tom@gmail.com
                    [4] => Hello tom how are you?
                    [5] => 2013-01-03 14:54:07
                )

            [1] => Array
                (
                    [0] => Array
                        (
                            [0] => 12
                            [1] => Yes i am fine.
                            [2] => Arun
                            [3] => arun@gmail.com
                            [4] => 2013-01-03 14:55:22
                        )
                )
        )
    [1] => Array
        (
            [0] => Array
                (
                    [0] => 12
                    [1] => 110
                    [2] => Tom
                    [3] => Tom@gmail.com
                    [4] => Hello tom how are you.
                    [5] => 2013-01-03 14:54:07
                )

            [1] => Array
                (
                    [0] => Array
                        (
                            [0] => 12
                            [1] => Yes i am fine
                            [2] => Arun
                            [3] => arun@gmail.com
                            [4] => 2013-01-03 14:55:22
                        )
                    [1] => Array
                        (
                            [0] => 12
                            [1] => Yes i am fine
                            [2] => Arun
                            [3] => arun@gmail.com
                            [4] => 2013-01-03 14:55:22
                        )
                )
        )
    [2] => Array
        (
            [0] => Array
                (
                    [0] => 12
                    [1] => 110
                    [2] => Tom
                    [3] => Tom@gmail.com
                    [4] => Hello tom how are you.
                    [5] => 2013-01-03 14:54:07
                )
            [1] => Array
                (
                    [0] => Array
                        (
                            [0] => 12
                            [1] => Yes i am fine
                            [2] => Arun
                            [3] => arun@gmail.com
                            [4] => 2013-01-03 14:55:22
                        )
                    [1] => Array
                        (
                            [0] => 12
                            [1] => Yes i am fine
                            [2] => Arun
                            [3] => arun@gmail.com
                            [4] => 2013-01-03 14:55:22
                        )
                [2] => Array
                        (
                            [0] => 12
                            [1] => Yes i am fine
                            [2] => Arun
                            [3] => arun@gmail.com
                            [4] => 2013-01-03 14:55:22
                        )
                )
        )
  • 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-16T20:02:14+00:00Added an answer on June 16, 2026 at 8:02 pm

    This should work:

    function cmp($a, $b)
    {
        return count($a[1]) > count($b[1]) ? -1 : 1;
    }
    
    usort($data, 'cmp');
    

    Or if you are using PHP 5.3.0 or greater, you can use:

    usort($data, function ($a, $b) {
        return count($a[1]) > count($b[1]) ? -1 : 1;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having one array like this. The tree structure of this array is
I have one array that contains some settings that looks like basically like this:
I'm having a brain fart right now. I'm pulling questions and possible answers from
I am still having issues copying the part of one array to another. I
I am having one heck of a hard time trying to figure this out.
I am having one Gtk+ and C application in which i want to set
I am having one flow field manager added on screen & in that manager
Ok this is one of those trickier than it sounds questions so I'm turning
I am having array like bellow.I don't understand how it is created. xyz Object
I am having this issue I have been struggling with for sometime and now

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.