npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@trandx/sortable

v1.0.5

Published

[![Start](https://img.shields.io/github/stars/Trandx/sortable?style=flat-square)](https://github.com/Trandx/sortable) [![Total Downloads](https://img.shields.io/github/downloads/trandx/sortable/total)](https://www.npmjs.com/package/@trandx/sortable) [![Kn

Downloads

22

Readme

Sortable

Inspired from Fast-sort

Start Total Downloads Known Vulnerabilities Open Source Love MIT Licence

NPM Package

Sortable is a lightweight (311 bytes gzip), zero-dependency sorting library with TypeScript support. Its easy-to-use and flexible syntax, combined with incredible speed put than Fast-sort library. It's a top choice for developers who seek efficient, reliable, and customizable sorting solutions.

Quick examples

  import { sort } from 'sortable';

  // Sort flat arrays
  const ascSorted = sort([1,4,2]).asc(); // => [1, 2, 4]
  const descSorted = sort([1, 4, 2]).desc(); // => [4, 2, 1]

  // Sort users (array of objects) by firstName in descending order
  const sorted = sort(users).desc(u => u.firstName);

  // Sort users in ascending order by firstName and lastName
  const sorted = sort(users).asc([
    u => u.firstName,
    u => u.lastName
  ]);
  // Sort users in ascending order by firstName and lastName
  const sorted = sort(users).asc([
    "firstName",
    u => u.lastName,
    "author.lastName"
  ]);

  // Sort users ascending by firstName and descending by city
  const sorted = sort(users).by([
    { asc: u => u.created_at },
    { desc: ["city"] }
  ]);

  // Sort based on computed property
  const sorted = sort(repositories).desc(r => (r.openIssues + r.closedIssues));

  // Sort using string for object key
  // Only available for root object properties
  const sorted = sort(users).asc('firstName');

Running online code link

For running code you can check here

Fore more examples check unit tests.

NOTE: This library sort automatically date, string, number and booleen datas. it help you to give more sorting precision if you have same field value. for example if you've same username, the second precision that you give (created_at) is for have sorting differentiation.

More examples

  // Sorting values that are not sortable will return same value back
  sort(null).asc(); // => null
  sort(33).desc(); // => 33
  sort('john').by({asc:true}); // => john

  // By default fast-sort sorts null and undefined values to the
  // bottom no matter if sorting is in asc or decs order.
  // If this is not intended behaviour you can check "Should create sort instance that sorts nil value to the top in desc order" test on how to override
  const addresses = [{ city: 'Split' }, { city: undefined }, { city: 'Zagreb'}];
  sort(addresses).asc(); // => Split, Zagreb, undefined

Running

Install via package manager

npm i @trandx/sortable or pnpm i @trandx/sortable

To run benchmark on your PC follow steps from below

  1. git clone https://github.com/Trandx/sortable.git
  2. cd into the directory
  3. pnpm install
  4. pnpm start

In case you notice any irregularities in benchmark or you want to add sort library to benchmark score please open issue here

Author

alt text