GithubHelp home page GithubHelp logo

surrealdb / lexicmp Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 1.0 341 KB

Library for comparing and sorting strings lexicographically

Home Page: https://docs.rs/lexicmp

License: Apache License 2.0

Rust 100.00%
lexicographic-sort lexicographical rust transliteration unicode

lexicmp's Introduction

lexicmp

The lexicmp library enables comparing and sorting strings using lexicographical and natural sorting semantics. This means that any Unicode characters such as á or ß are treated like their closest ASCII character: á is treated as a, ß is treated as ss. This library also ensures that emojis are transliterated before being sorted. When using natural sorting, numbers are sorted naturally, ensuring that 50 is sorted before 100, skipping characters that aren't alphanumeric, ensuring that f-5 is next to f5. If different strings have the same ASCII representation (e.g. "Foo" and "fóò"), it falls back to the default method from the standard library, ensuring that sorting is always deterministic, and constitute a total order.

docs.rs Crates.io

Features

  • Compare strings lexicographically
  • Compare strings naturally with support for numbers
  • Compare strings sensitively and case insensitively
  • Compare strings, skipping non-alphanumeric characters
  • Compare strings lexicographically and naturally together
  • Handle unicode characters, foreign languages, and emoji characters
  • Does not allocate memory on the heap, instead using iterators

Original

This code is forked originally from lexical-sort, licensed under the Apache 2.0 and MIT licenses.

lexicmp's People

Contributors

aloso avatar tobiemh avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

nitroxis

lexicmp's Issues

Panic due to attempt to multiply with overflow

Hi,

when comparing strings using natural_lexical_cmp, the code can cause a attempt to multiply with overflow panic when the strings contain a number long enough to overflow a u64.

It might be best to just fall back to simple character comparison if a number exceeds a certain length.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.