Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to sort object keys #64

Closed
zaim opened this issue Jan 8, 2015 · 4 comments
Closed

Add option to sort object keys #64

zaim opened this issue Jan 8, 2015 · 4 comments

Comments

@zaim
Copy link

zaim commented Jan 8, 2015

Consider adding an option to sort object keys. This could be useful when using query strings for (or as part of) a unique key, ensuring the order of property declaration doesn't affect output.

qs.stringify({ a: 'b', z: 'x' }) === 'a=b&z=x';
qs.stringify({ z: 'x', a: 'b' }) === 'z=x&a=b';
qs.stringify({ z: 'x', a: 'b' }, { sort: true }) === 'a=b&z=x';

I can work on this and provide pull request if okay.

@adam-beck
Copy link

I think a compare function would be more beneficial. Just a simple boolean would limit how the object keys are sorted.

@Marsup
Copy link
Contributor

Marsup commented Feb 24, 2015

Doesn't mean it can't be both. It'll probably be faster without the function call.

@bobylito
Copy link

I need this, and I am to work on that today, if you don't mind.

@nlf nlf closed this as completed in 4b434ed Oct 7, 2015
nlf added a commit that referenced this issue Oct 7, 2015
Add an option to sort the keys in the query string FIX #64
@ljharb
Copy link
Owner

ljharb commented Jan 17, 2016

Fixed by #120

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants