Forum
    • Categories
    • Register
    • Login

    No-argument sort() is a no-op on strings - bug?

    Scheduled Pinned Locked Moved Bug Reports
    4 Posts 2 Posters 16 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • dannytaurusD
      dannytaurus
      last edited by dannytaurus

      A no-argument (not passing a comparator function) call to sort() on strings in an unexpected no-op.

      Seems like a bug?

      Docs: https://docs.hise.dev/scripting/scripting-api/array/index.html#sort

      CleanShot 2026-09-04 at 15.19.11@2x.png

      const var n = [3, 1, 2];
      const var s = ["b", "c", "a"];
      
      Console.print(trace(n.sort()));        // ✅ [3, 1, 2] becomes [1, 2, 3]
      Console.print(trace(s.sort()));        // ❌ stays ["b", "c", "a"]
      Console.print(trace(s.sortNatural())); // ✅ properly sorted as ["a", "b", "c"]
      

      sortNatural() is the function that works for sorting strings.

      HISE dev latest / super.engineering + Claude Fable / Figma + Affinity
      Meat Beats: https://meatbeats.com
      Klippr Video: https://klippr.video

      David HealeyD 1 Reply Last reply Reply Quote 0
      • David HealeyD
        David Healey @dannytaurus
        last edited by

        @dannytaurus I made a video about sorting and I hadn't even noticed the docs are wrong.

        https://www.youtube.com/watch?v=qeUq-M6CgTs

        Free HISE Bootcamp Full Course for beginners.
        YouTube Channel - HISE tutorials
        My Patreon - More HISE tutorials

        dannytaurusD 1 Reply Last reply Reply Quote 1
        • dannytaurusD
          dannytaurus @David Healey
          last edited by

          @David-Healey So you think the docs are wrong, rather than it being a bug?

          If it's intentional behaviour I won't file a fix. But if it's a bug, it should get fixed because it's one of those silent time-wasters that can grind productivity to a halt.

          HISE dev latest / super.engineering + Claude Fable / Figma + Affinity
          Meat Beats: https://meatbeats.com
          Klippr Video: https://klippr.video

          David HealeyD 1 Reply Last reply Reply Quote 0
          • David HealeyD
            David Healey @dannytaurus
            last edited by

            @dannytaurus said in No-argument sort() is a no-op on strings - bug?:

            So you think the docs are wrong, rather than it being a bug?

            Could be either

            Free HISE Bootcamp Full Course for beginners.
            YouTube Channel - HISE tutorials
            My Patreon - More HISE tutorials

            1 Reply Last reply Reply Quote 1
            • First post
              Last post

            12

            Online

            2.5k

            Users

            13.9k

            Topics

            121.4k

            Posts