• Resolved lava33

    (@lava33)


    Hi
    Can you please let me know how I can arrange price attributes in numerical order.

    They are currently displayed like this:
    £10, £100, £150, £20, £30, £40, £50, £75

    I want them to display like this:
    £10, £20, £30, £40, £50, £75, £100, £150

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi

    We can use usort method here which is Natural order string comparison

    follow below

    <?php
    $arr1 = array(“£10″,”£100″,”£150″,”£20″,”£30″,”£40″,”£50″,”£75″);

    usort($arr1,”strnatcmp”);

    print_r($arr1);
    ?>

    output:

    Array ( [0] => £10 [1] => £20 [2] => £30 [3] => £40 [4] => £50 [5] => £75 [6] => £100 [7] => £150 )

    Thank you
    Praveen Valmiki

    AJ a11n

    (@amandasjackson)

    Hi @lava33

    If I understand correctly, you should be able to use the Default sort order name (numeric) to do this


    Link to image: https://cld.wthms.co/5y23jl

    AJ a11n

    (@amandasjackson)

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Sorting attributes numerically’ is closed to new replies.