Shell APIs violate ECMAScript's object property order spec

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Won't Fix
    • Priority: Minor - P4
    • None
    • Affects Version/s: 3.5.5
    • Component/s: Shell
    • Server Tooling & Methods
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      If I want to add a sorting step into my aggregation pipeline which should sort the input documents according to two (or more) fields I can do so by adding a $sort stage (whose API is described here):

      { $sort: { <field1>: <sort order>, <field2>: <sort order> ... } }
      

      Given the current API the order in which the individual field sorting operations (sort by field1, then by field2, etc.) are applied is determined by the field order of the object that is assigned to the $sort property.
      But this violates the ECMAScript spec...
      E.g. ECMAScript 5 spec says that object properties are intrinsically unordered.
      And ECMAScript 6 spec defines a specific object property order, but it does not equal to the order which the object properties have been defined in (see: https://esdiscuss.org/topic/nailing-object-property-order).

      So it would be nice to have a $sort API that doesn't break the ECMAScript semantics, e.g. by using a strictly ordered data structure like an array:

      { $sort: [ [<field1>, <sort order>], [<field2>, <sort order>], ... ] }
      

            Assignee:
            Backlog - Server Tooling and Methods (STM) (Inactive)
            Reporter:
            Philipp Tarasiewicz
            Votes:
            0 Vote for this issue
            Watchers:
            17 Start watching this issue

              Created:
              Updated:
              Resolved: