Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/object/index.ts>sortKeys

A JavaScript extension package for building strong and modern applications.
Latest
function sortKeys
import { sortKeys } from "https://deno.land/x/ayonli_jsext@v0.9.72/object/index.ts";

Creates an object with sorted keys (in ascending order) of the original object.

NOTE: Symbol keys are not sorted and remain their original order.

NOTE: This function only operates on plain objects and arrays.

Examples

Example 1

import { sortKeys } from "@ayonli/jsext/object";

const obj = sortKeys({ foo: "Hello", bar: "World" });

console.log(JSON.stringify(obj)); // { "bar": "World", "foo": "Hello" }

Type Parameters

T extends object

Parameters

obj: T
optional
deep = [UNSUPPORTED]