A custom sort command line tool using Python and Click.
Project description
📜 Для проєкту custom-sort (README.md)
# Custom Sort CLI (`csort`)
[](https://badge.fury.io/py/custom-sort-cli)
[](https://github.com/bohdanfariyon/custom-sort/actions)
A simple, lightweight command-line utility written in Python to sort lines of text files, mimicking the basic functionality of the GNU `sort` command. This tool is built using the `click` library.
---
## 🚀 Features
* **Standard Input/Output**: Works with files or standard I/O streams (`stdin`/`stdout`).
* **Reverse Sort**: Sort lines in descending order.
* **Numeric Sort**: Sort based on the numerical value of lines.
* **Unique Lines**: Output only unique lines from the input.
* **File Output**: Write the sorted result directly to a specified file.
* **Dockerized**: Comes with a `Dockerfile` for easy containerization.
---
## 📦 Installation
You can install the package directly from PyPI:
```bash
pip install custom-sort-cli
🛠️ Usage
The main command is csort. You can pass it a file path or pipe data into it.
Basic Sorting
Sort lines in myfile.txt and print to the console.
csort myfile.txt
Sorting from Standard Input
cat myfile.txt | csort
Command Options
-
-r, --reverse: Sort in reverse (descending) order.csort -r myfile.txt
-
-n, --numeric: Perform a numeric sort. Useful for files containing numbers.# For a file `numbers.txt` with: # 10 # 2 # 1 # 50 csort -n numbers.txt # Output: # 1 # 2 # 10 # 50
-
-u, --unique: Filter out duplicate lines.csort -u duplicates.txt
-
-o, --output <filename>: Write the output to a file instead of the console.csort myfile.txt -o sorted_file.txt
🐳 Docker Usage
You can also build and run this tool as a Docker container.
-
Build the image:
docker build -t csort-app .
-
Run the container:
To see the help message:
docker run --rm csort-app --help
To sort a file from your current directory, you need to mount it as a volume:
# This command mounts the current directory to /data inside the container # and tells csort to read the file /data/myfile.txt docker run --rm -v "$(pwd)":/data csort-app /data/myfile.txt
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file custom_sort_cli-0.1.0.tar.gz.
File metadata
- Download URL: custom_sort_cli-0.1.0.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
070569c60336847a8b8808af7d5d88e9da659f6ffe3b01a03279bffb8df68cba
|
|
| MD5 |
fea21dffe8e0b3682ab09a941bc2649c
|
|
| BLAKE2b-256 |
ff64794124a3c4e3d6ed2570e59049d9c416d7e3dc579ea7c5c59fbd814bfac9
|
File details
Details for the file custom_sort_cli-0.1.0-py3-none-any.whl.
File metadata
- Download URL: custom_sort_cli-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8d002c5a1238b4ed1a1ed8de1ef61a2de6206d54559032cb566ce47e41131ca
|
|
| MD5 |
b9233d2ee39b86e0f20ed672b31a6920
|
|
| BLAKE2b-256 |
aa25d76b972d67735868be54838991ec2849481a746e8a8f982663170f5ad087
|