Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sorted

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sorted

  • 2.2.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Sorted

Build Status

Sorted at it's core is a set of objects that let you sort many different attributes in weird and wonderful ways.

Example

The secret sauce is the Sorted::Set object, in this example we 'toggle' email:

require 'sorted/set'

a = Sorted::Set.new([['email', 'asc'], ['name', 'asc']])
b = Sorted::Set.new([['email', 'asc'], ['phone', 'asc']])

s = a.direction_intersect(b)

s.to_a #=> [['email', 'desc'], ['phone', 'asc'], ['name', 'asc']]

The best way to think about this is to imagine a spreed sheet and what happens when you sort by various columns, Sorted::Set pretty much just does that.

Parsers/Encoders

Parsers return a Sorted::Set that can then be used by an encoder:

require 'sorted/uri_query'

set = Sorted::URIQuery.parse('name_asc!email_asc')
Sorted::SQLQuery.encode(set) #=> 'name ASC email ASC'

Currently implemented:

  • Sorted::SQLQuery
  • Sorted::URIQuery
  • Sorted::JSONQuery
  • Sorted::ElasticsearchQuery
  • Sorted::ParamsQuery

Projects

FAQs

Package last updated on 26 Jun 2019

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc