0.0
The project is in a healthy, maintained state
A Ruby gem that implements sorting algorithms specifically designed for Ukrainian language strings, ensuring proper handling of unique characters and collation rules.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

Ukrainian Sort Gem

Мотивація

Сортування українського тексту не працює у Ruby через стандартний механізм сортування, який базується на Unicode-кодах. Результат не відповідає порядку українського алфавіту.

Ця бібліотека забезпечує правильне сортування відповідно до українського алфавіту, вирішуючи проблеми, як-от розташування 'ґ' та 'є'.

Motivation

Sorting Ukrainian text correctly is a challenge with Ruby's default sorting mechanism. By default, Ruby sorts strings based on Unicode code points, which does not align with the Ukrainian alphabet.

This gem ensures proper sorting according to the Ukrainian alphabet, addressing discrepancies like the placement of 'ґ' and 'є'.

Приклад / Example

  • Стандартне сортування Ruby / Default sort in Ruby:
["г", "е", "и", "й", "є", "і", "ї", "ґ"]
  • ukrainian_sort gem:
["г", "ґ", "е", "є", "и", "і", "ї", "й"]

Unicode значення / Unicode values

  • г -> 1075
  • ґ -> 1169
  • е -> 1077
  • є -> 1108
  • и -> 1080
  • і -> 1110
  • й -> 1081
  • ї -> 1111

Сортування за Unicode-кодами (стандартне для Ruby) / Sort by Unicode (default in Ruby)

["г", "е", "и", "й", "є", "і", "ї", "ґ"]

ukrainian_sort gem:

["г", "ґ", "е", "є", "и", "і", "ї", "й"]

Installation

Add this line to your application's Gemfile:

gem 'ukrainian_sort'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install ukrainian_sort

Usage

To sort an array of Ukrainian strings:

require 'ukrainian_sort'

words = ["яблуко", "ґава", "виноград", "єдинорог"]
sorted_words = UkrainianSort.sort(words)
puts sorted_words

Testing

Run the test suite to ensure everything is working correctly:

$ rspec

Sponsor

Development of this gem is sponsored by tseivo.com