react-json-view icon indicating copy to clipboard operation
react-json-view copied to clipboard

support custom sort method for object keys

Open janryWang opened this issue 5 years ago • 2 comments

Currently there is only one sortKeys property to control automatic sorting, but I hope it can be specified manually

janryWang avatar Jan 30 '21 16:01 janryWang

@janryWang can you give an example of how you want to be able to sort differently?

mac-s-g avatar Feb 03 '21 21:02 mac-s-g

I have a similar requirement for my usage, not yet high priority, but I expect I'll get around to it eventually.

In my case I have a named set of 'states' (think board game phases of a turn) which I'd like consistently ordered.

I expect if I need to develop things myself, I'd pass in an array of strings as a new parameter 'customSortOrder'. If a key is in the array, it gets sorted according to its array position, else it gets placed behind fields which appear in the array.

From my current experience playing with the codebase I don't expect it'd be too hard, if someone wanted to get their toes wet with it.

chad-autry avatar Apr 24 '21 14:04 chad-autry