masklinn 13 hours ago

… why are you calling it ordered when it’s sorted rather than, well, ordered?

  • habedi0 12 hours ago

    I picked that name (`ordered`, as in `put into and kept in an arrangement`) when I started the project a few months ago and decided to keep it.

  • LandR 11 hours ago

    Whats the difference between ordered and sorted ?

    • Galanwe 11 hours ago

      I was confused as well. According to the internet, "ordered" is a material property of a container, it does not depend on the actual values inserted, but rather the insertion sequencing. (e.g. a queue or a stack is ordered, a set is unordered). "sorted" refers to the actual values in the container.

      So a list is ordered, but can be sorted or not. A set is unordered but sorted. I guess a priority queue is ordered and sorted.

      • cb321 10 hours ago

        Being truly unordered like a set is not something you can do in a physical computer program unlike a mathematical abstraction. Anything stored is "ordered" in some way, either explicitly by virtual (or physical) memory addresses or implicitly by some kind of storage map equation (like a bitmap/bitvector or N-D C/Fortran array). It just might not be a useful ordering. (I.e., you may have to loop and compare.)

        One might qualify such as "system-ordered", or in the Python insert-ordered dict, qualify with "insertion-ordered", though hash tables in general are sort of a melange of hash-ordering. The same container may also support efficient iteration in multiple orders (e.g., trees often support key order as well as another order, like VM/node pool slot number order).

        So, in this context (where things are obviously elements of a computer program), it isn't obvious that hair-splitting over ordered vs. sorted in their purest senses is very helpful when what is really missing is qualification.

        Of course, like in many things, people tend to name computer program elements after their abstractions. This is where confusion often comes from (and not just in computing!) .. borrowing the names without all the properties (or maybe with more properties, as in this case, though that is all probably a bit iffy with the frailty of how you enumerate/decompose properties).

        EDIT: In a similar way, in a realized computer, almost any "set" representation can also be a "map". You just add satellite data. Even a bit-vector can have a "parallel vector" with satellite data you access after the bits (which could even be pointful in terms of cache access). This can cause similar confusions to the "ordered" vs. "sorted" stuff.

    • 4b11b4 4 hours ago

      order is a general concept which builds on top of the concept of equality. If they are not equal, then what are they? We can manually define an order for a type to determine which is lesser or greater. once you have this rule (the order), then you can sort

      effectively you could think of them the same, or that sorting is an application of using the order rules for a given type