1
0
Fork
You've already forked natural-ordering-zig
0
Sort smart. Sort naturally. "a1" < "a10"
  • Zig 100%
2025年05月21日 13:42:03 +03:00
src Add pub to compare 2025年05月21日 13:42:03 +03:00
.gitignore Init 2025年05月20日 21:39:45 +03:00
build.zig Init 2025年05月20日 21:39:45 +03:00
build.zig.zon Fix fingerprint after changing package name 2025年05月21日 13:40:48 +03:00
LICENSE Init 2025年05月20日 21:39:45 +03:00
readme.md Init 2025年05月20日 21:39:45 +03:00

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.