Skip to content

url: add sort() to URLSearchParams #10760

Description

@jasnell

whatwg/url#26 proposes adding a sort() capability to URLSearchParams. The idea would be to have a simple default lexical sort of keys. If added, we would need to add this to the API

Activity

  1. added
    whatwg-urlIssues and PRs related to the WHATWG URL implementation.
    on Jan 12, 2017
  2. targos commented on Jan 12, 2017

    @targos
    Member

    PR: whatwg/url#199

    Note: the current proposal requires a stable sorting algorithm.

  3. TimothyGu commented on Jan 22, 2017

    @TimothyGu
    Member

    whatwg/url#199 has been merged.

    Is there an existing stable sort function in the code base? If not, I'll just make a simple insertion sort (or copy the one in V8), which is stable.

  4. changed the title [-]url: track WHATWG URL issue #26[/-] [+]url: add sort() to URLSearchParams[/+] on Jan 22, 2017
  5. self-assigned this
    on Jan 28, 2017
  6. joyeecheung commented on Jan 31, 2017

    @joyeecheung
    Member

    If we use an array of tuples as the underlying data structure instead of flattening them out, we can just use Array.prototype.sort. Any reason they must be flattened?

  7. joyeecheung commented on Jan 31, 2017

    @joyeecheung
    Member

    Also I remember there was discussion about moving the parsing bit to C++, for reference, blink does it with a Vector<std::pair<String, String>> and gecko does it with a nsTArray<Param>(essentially a vector with pair of strings too)

  8. TimothyGu commented on Feb 1, 2017

    @TimothyGu
    Member

    @joyeecheung, we can't use array.sort because it is not guaranteed to be stable, while the WHATWG spec does. In C++, creating new arrays for each tuple seems to be fairly expensive, so I decided on a flattened array instead.

  9. added a commit that references this issue on Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

whatwg-urlIssues and PRs related to the WHATWG URL implementation.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions