Skip to content

Feature: Only sort first N levels #17

@Floriferous

Description

@Floriferous

It would be useful if I could sort an object only at its first level, and not sort all the subkeys as well. And maybe some people would want to sort the first 2 levels, but not the next ones.

For example:

// Before sort
const countries = {
  CH: {
    name: 'Switzerland',
    description: 'Chocolate and watches',
  },
  BE: {
    name: 'Belgium',
    description: 'Beer and fries',
  },
};

// Output after sort, 1st level only
const countries = {
  BE: {
    name: 'Belgium',
    description: 'Beer and fries',
  },
  CH: {
    name: 'Switzerland',
    description: 'Chocolate and watches',
  },
};

In this case, I want the first level sorted, but not the second, because it makes more sense to keep the name key first for ease of reading.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions