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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:34:02+00:00 2026-06-06T05:34:02+00:00

I am studying sort_flags at this page on PHP Manual. And I don’t understand

  • 0

I am studying sort_flags at this page on PHP Manual.

And I don’t understand what difference each of these flags represents.

There are only 6 flags, can someone please help me to understand the difference between them. Maybe with some examples. I would be very thankful.

  • 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-06T05:34:04+00:00Added an answer on June 6, 2026 at 5:34 am

    Array used for testing:

    $toSort = array(2, 1, "img1", "img2", "img10", 1.5, "3.14", "2.72");
    

    Note that 3.14 & 2.72 are strings.

    Using SORT_REGULAR flag (compare items normally):

    Array
    (
        [0] => 2.72
        [1] => 3.14
        [2] => img1
        [3] => img10
        [4] => img2
        [5] => 1
        [6] => 1.5
        [7] => 2
    )
    

    Using SORT_NUMERIC flag (compare items numerically, so 3.14 is sorted as number not a string):

    Array
    (
        [0] => img10
        [1] => img1
        [2] => img2
        [3] => 1
        [4] => 1.5
        [5] => 2
        [6] => 2.72
        [7] => 3.14
    )
    

    Using SORT_STRING flag (SORT_LOCALE_STRING works similary, but depends on current locale, all values are treated as strings):

    Array
    (
        [0] => 1
        [1] => 1.5
        [2] => 2
        [3] => 2.72
        [4] => 3.14
        [5] => img1
        [6] => img10
        [7] => img2
    )
    

    Using SORT_NATURAL flag (note order of img* strings, it is natural):

    Array
    (
        [0] => 1
        [1] => 1.5
        [2] => 2
        [3] => 2.72
        [4] => 3.14
        [5] => img1
        [6] => img2
        [7] => img10
    )
    

    SORT_FLAG_CASE can be combined with SORT_STRING or SORT_NATURAL to do case-insensitive sort e.g.:

    // works like SORT_NATURAL but is case-insensitive
    sort($toSort, SORT_NATURAL | SORT_FLAG_CASE);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am studying a guide in which scaffold is mentioned. I don't understand what
I am studying PHP and there is polymorphism example at the website i am
I'm studying this code, and there is a + in the color function which
I was studying the radix sort algorithm but I could not understand some of
After studying TCP/UDP difference all week, I just can't decide which to use. I
While studying for the Zend PHP Exam I came across the following contradicting information:
I'm studying both of these approaches to include transactions in my Spring application. As
I've been studying Visibility issue in PHP (public, private, protected) and wondered how is
I'm studying for upcoming interviews and have encountered this question several times (written verbatim)
While studying for the SCJP 6 exam, I ran into this question in a

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.