![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
better-sort
Advanced tools
Syntactic sugar wrapper over JS sort function with better readability
Zero-dependency minimal package (two functions) to provide better-readable (albeit more verbose) wrapper over JS default Array.sort()
. Fully typed.
Prevents errors when interchanging signs in the native Array.sort()
function like this:
foo.sort((a, b) => (a.date.isBefore(b.date) ? -1 : 1))
- at the first glance, is this sorted in ASC or DESC order??
Usage:
import { sortAsc } from "./src/index";
const array = [3, 1, 4, 1, 5, 9, 2, 6];
const sortedArray = sortAsc({
array,
firstIsGreater: (a, b) => a > b, // Compare function that returns boolean
});
console.log(sortedArray); // [1, 1, 2, 3, 4, 5, 6, 9]
console.log(array); // [3, 1, 4, 1, 5, 9, 2, 6] - keeps the original array intact
You can provide areEqual
function parameter to ensure stability of the sorting function. Otherwise it sorts equal elements in non-deterministic order.
import { sortAsc } from "./src/index";
// The sortAsc function is a stable sort when `areEqual` is provided, meaning that it preserves the original input order of elements that are equal.
const inputArray = [
{ name: "John", age: 25 },
{ name: "Alice", age: 30 },
{ name: "Bob", age: 20 },
{ name: "Mike", age: 25 },
];
const sortedArray = sortAsc({
array: inputArray,
firstIsGreater: (a, b) => a > b,
areEqual: (a, b) => a === b,
});
console.log(sortedArray); // [{ name: "Bob", age: 20 }, { name: "John", age: 25 }, { name: "Mike", age: 25 }, { name: "Alice", age: 30 }] - keeps equal elements in order they appear in input
FAQs
Syntactic sugar wrapper over JS sort function with better readability
The npm package better-sort receives a total of 2 weekly downloads. As such, better-sort popularity was classified as not popular.
We found that better-sort demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.