forked from knightpp/natural-ordering-zig
Sort smart. Sort naturally. "a1" < "a10"
- Zig 100%
| src | Add pub to compare | |
| .gitignore | Init | |
| build.zig | Init | |
| build.zig.zon | Fix fingerprint after changing package name | |
| LICENSE | Init | |
| readme.md | Init | |
natural-ordering-zig
This is Zig conversion of https://github.com/sourcefrog/natsort.
Add to zig
Get the dependency
zig fetch --save https://codeberg.org/knightpp/natural-ordering-zig
add in your build.zig
const natord_dep = b.dependency("natural_ordering", .{
.target = target,
.optimize = optimize,
});
const natord_mod = natord_dep.module("natord");
What is it?
When you sort strings you can produce unexpected results, because sorting does not handle numbers correctly.
For example dates
2000年1月10日
2000年1月2日
1999年12月25日
2000年3月23日
1999年3月3日
should be naturally sorted
1999年3月3日
1999年12月25日
2000年1月2日
2000年1月10日
2000年3月23日
The same goes to numbers a < a0 < a1 < a1a < a1b < a2 < a10 < a20.
See original README.md for more info.