What algorithm does [SORTED v] of () use?

I'm just curious on what algorithm

[sorted V] of @list

uses

Whatever the Javascript library provides. So it's probably quicksort; that's what most libraries use, I think.

it's slightly more interesting than just "whatever JavaScript does", Snap's generic sorting works with any combination of first-class data. It sorts / groups them by the order

list, text, number, Boolean, color, command, reporter, predicate, costume, sound, sprite, stage, nothing, undefined
  • lists are sorted primarily descending by their length, secondarily by the contents of their columns from left to right, recursively.
  • colors are sorted by their numerical r-g-b values.
  • blocks are sorted by their label texts (secondary, primarily by their type).
  • objects by their names (also primarily by their type: costume, sound, sprite, stage).

Oh, yes, I should have said that figuring what to sort on is interesting, but I took the question to be, once the sort keys are determined, what sorting algorithm do we use. And that's the question to which I think the answer is "whatever algorithm JS uses."

oh, is "nothing" its own datatype?

I would've assumed blank items were strings

same. but what jens posted, and snap error messages, I think suggest otherwise.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.