Skip to content

asort/arsort/sort compare numeric strings as bytes, php compares them as numbers #308

Closed

Description

@blacktrs

Summary

asort/arsort/sort compare numeric strings as bytes, php compares them as numbers.

Repro

<?php
$a = ["a" => "10", "b" => "9", "c" => "1e1"];
asort($a);
echo json_encode($a), "\n";
$l = ["10", "9", "1e1"];
sort($l);
echo json_encode($l), "\n";

Expected (php)

{"b":"9","a":"10","c":"1e1"}
["9","10","1e1"]

Actual (manticore 6df3b897, Darwin arm64)

{"b":"9","a":"10","c":"1e1"}
["10","1e1","9"]

Tracking

Known-bug repro: tests/aot/repro/wrong/asort_numeric_string_values.php — bash tests/aot/xfail.sh -k asort_numeric_string_values reports XFAIL while this is open and XPASS once it is fixed; then move the repro into tests/aot/cases/ and close this issue.

Activity

  1. added
    bug
    wrong-answer
    on Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugwrong-answer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions