textproc/py-natsort 8.4.0nb1 NetBSD
Natural sorting for python
- System
- NetBSD
- Repository
- pkgsrc
- Maintainer
- [email protected]
- License
- mit
- Categories
- textproc, python
- Package size
- 57.9 KiB, 354.2 KiB installed
Description
When you try to sort a list of strings that contain numbers, the normal python sort algorithm sorts lexicographically, so you might not get the results that you expect:
>>> a = ['a2', 'a9', 'a1', 'a4', 'a10'] >>> sorted(a) ['a1', 'a10', 'a2', 'a4', 'a9']
Notice that it has the order ('1', '10', '2') - this is because the list is being sorted in lexicographical order, which sorts numbers like you would letters (i.e. 'b', 'ba', 'c').
natsort provides a function natsorted that helps sort lists "naturally", either as real numbers (i.e. signed/unsigned floats or ints), or as versions. Using natsorted is simple:
>>> from natsort import natsorted >>> a = ['a2', 'a9', 'a1', 'a4', 'a10'] >>> natsorted(a) ['a1', 'a2', 'a4', 'a9', 'a10']
natsorted identifies numbers anywhere in a string and sorts them naturally.
In the other systems
| System | Port | Version |
|---|---|---|
| NetBSD | textproc/py-natsort | 8.4.0nb1 |
| OpenBSD | textproc/py-natsort | 8.4.0p2 |
| DragonFly | devel/py-natsort | 8.4.0_1 |
Install
Binary package:
pkgin install py311-natsort
From pkgsrc:
cd /usr/pkgsrc/textproc/py-natsort && make install clean
Packages
The version each package repository carries. “-” means the repository builds no package of it, “n/a” that there is no such repository.
| Repository | Version |
|---|---|
| NetBSD 10.1 x86_64 | 8.4.0nb1 |
| NetBSD 10.1 aarch64 | 8.4.0nb1 |
| SmartOS / illumos x86_64 | 8.4.0nb1 |
| macOS 15 arm64 | 8.4.0nb1 |
Dependencies
Run dependencies 1
Configuration
No options to configure.
- Service scripts
- none
- Flavors
py312-natsort-8.4.0nb1,py313-natsort-8.4.0nb1,py314-natsort-8.4.0nb1