Skip to main content

Simple sort utility implemented in Python with Click

Project description

nastya-sort

Lightweight implementation of Unix nastya-sort utility in Python with Click framework.

Features

  • ✅ Sort lines from files or stdin
  • ✅ Numeric sorting with -n flag
  • ✅ Reverse order with -r flag
  • ✅ Docker support
  • ✅ Compatible with Unix sort behavior

Installation

From source

git clone https://github.com/YOUR-USERNAME/nastya-sort.git
cd nastya-sort
pip install -e .

Using Docker

# Or build locally
docker build -t nastya-sort .

Usage

Command Line Interface

# Sort lines from stdin
echo -e "banana\napple\ncherry" | sort

# Sort file contents
sort file.txt

# Numeric sort
echo -e "10\n2\n100\n20" | sort -n
# Output: 2, 10, 20, 100

# Reverse order
sort -r file.txt

# Combine options
sort -rn numbers.txt

Docker Usage

# Sort from stdin
echo -e "3\n1\n2" | docker run -i ghcr.io/YOUR-USERNAME/nastya-sort:latest -n

# Sort file (mount current directory)
docker run -v $(pwd):/data ghcr.io/YOUR-USERNAME/nastya-sort:latest /data/file.txt

# Show help
docker run ghcr.io/YOUR-USERNAME/nastya-sort:latest --help

Command Options

Option Description
-n, --numeric Compare according to string numerical value
-r, --reverse Reverse the result of comparisons
-h, --help Show help message and exit

Examples

Basic Sorting

# Alphabetical sort
cat names.txt | nastya-sort

# Sort and save to file
nastya-sort input.txt > sorted.txt

Numeric Sorting

# Sort numbers correctly
echo -e "100\n20\n3\n1000" | nastya-sort -n
# Output:
# 3
# 20
# 100
# 1000

Reverse Sorting

# Descending order
echo -e "a\nc\nb" | nastya-sort -r
# Output:
# c
# b
# a

Combined with Other Tools

# Sort and remove duplicates
nastya-sort file.txt | uniq

# Sort CSV by second column
cut -d',' -f2 data.csv | nastya-sort -n

# Count and sort word frequency
cat text.txt | tr ' ' '\n' | nastya-sort | uniq -c | nastya-sort -rn

Development

Setup Environment

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install in development mode
pip install -e .

Building Docker Image

docker build -t nastya-sort .
docker run nastya-sort --help

Testing

# Test basic sorting
echo -e "c\na\nb" | nastya-sort

# Test numeric sorting
echo -e "10\n2\n1" | nastya-sort -n

# Test with Docker
echo -e "3\n1\n2" | docker run -i nastya-sort -n

CI/CD

This project uses GitHub Actions to automatically:

  • Build Docker images on every push to main
  • Run basic tests
  • Push images to GitHub Container Registry
  • Tag images with commit SHA and latest

Project Structure

nastya-sort/
├── nastya_sort/
│   ├── __init__.py       # Package version
│   └── cli.py            # CLI implementation
├── .github/
│   └── workflows/
│       └── docker-publish.yml  # CI/CD pipeline
├── Dockerfile            # Docker image definition
├── setup.py              # Package configuration
├── README.md             # This file
└── .gitignore           # Git ignore rules

License

MIT License

Author

Your Name
Email: you@example.com
GitHub: @YOUR-USERNAME

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nastya_sort_lnu-0.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nastya_sort_lnu-0.1.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file nastya_sort_lnu-0.1.0.tar.gz.

File metadata

  • Download URL: nastya_sort_lnu-0.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.24

File hashes

Hashes for nastya_sort_lnu-0.1.0.tar.gz
Algorithm Hash digest
SHA256 daf079b0079d2c5d42293ce5fcf2a6ace7564ee7feb1fb58df367266f983d34c
MD5 135ad028e365369e1e117e6842431fed
BLAKE2b-256 b2b75e4aa2d1bb3d1ac3e8a329c12e5815ec17522b9e351ecbae32094d5ead0c

See more details on using hashes here.

File details

Details for the file nastya_sort_lnu-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nastya_sort_lnu-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fb0c417836f8b361110898e33d9abfc77f9b5dba568035ec7bbc61322fe29cbb
MD5 df26b4e7d4231ea133c491d8c1ad6239
BLAKE2b-256 93fc7300b55ba9f0968ad227ed5d83e2ba05d6b733b92951e108055a6c0f947d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page