# nastya-sort
Lightweight implementation of Unix `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
```bash
git clone https://github.com/Nastia2004/nastya-sort-lnu.git
cd nastya-sort-lnu
pip install -e .
```
### Using Docker
```bash
# Or build locally
docker build -t nastya-sort .
```
## Usage
### Command Line Interface
```bash
# 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
```
## 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
```bash
# Alphabetical sort
cat names.txt | sort
# Sort and save to file
sort input.txt > sorted.txt
```
### Numeric Sorting
```bash
# Sort numbers correctly
echo -e "100\n20\n3\n1000" | sort -n
# Output:
# 3
# 20
# 100
# 1000
```
### Reverse Sorting
```bash
# Descending order
echo -e "a\nc\nb" | sort -r
# Output:
# c
# b
# a
```
### Combined with Other Tools
```bash
# Sort and remove duplicates
sort file.txt | uniq
# Sort CSV by second column
cut -d',' -f2 data.csv | sort -n
# Count and sort word frequency
cat text.txt | tr ' ' '\n' | sort | uniq -c | sort -rn
```
## Development
### Setup Environment
```bash
# Create virtual environment
python3 -m venv test
source test/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode
pip install -e .
```
### Building Docker Image
```bash
docker build -t nastya-sort .
docker run nastya-sort --help
```
### Testing
```bash
# Test basic sorting
echo -e "c\na\nb" | sort
# Test numeric sorting
echo -e "10\n2\n1" | sort -n
# Test with Docker
echo -e "3\n1\n2" | docker run -i nastya-sort -n
```
## 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
```
Raw data
{
"_id": null,
"home_page": "https://github.com/Nastia2004/nastya-sort-lnu",
"name": "nastya-sort-lnu",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "sort cli utility unix",
"author": "Nastya",
"author_email": "nastavasilik1@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/5c/18/ccd67f2062e2737b57071392e1ff1579da75503df65548aa4595d87f190c/nastya_sort_lnu-0.2.6.tar.gz",
"platform": null,
"description": "# nastya-sort\n\nLightweight implementation of Unix `sort` utility in Python with Click framework.\n\n## Features\n\n- \u2705 Sort lines from files or stdin\n- \u2705 Numeric sorting with `-n` flag\n- \u2705 Reverse order with `-r` flag\n- \u2705 Docker support\n- \u2705 Compatible with Unix sort behavior\n\n## Installation\n\n### From source\n\n```bash\ngit clone https://github.com/Nastia2004/nastya-sort-lnu.git\ncd nastya-sort-lnu\npip install -e .\n```\n\n### Using Docker\n\n```bash\n\n# Or build locally\ndocker build -t nastya-sort .\n```\n\n## Usage\n\n### Command Line Interface\n\n```bash\n# Sort lines from stdin\necho -e \"banana\\napple\\ncherry\" | sort\n\n# Sort file contents\nsort file.txt\n\n# Numeric sort\necho -e \"10\\n2\\n100\\n20\" | sort -n\n# Output: 2, 10, 20, 100\n\n# Reverse order\nsort -r file.txt\n\n# Combine options\nsort -rn numbers.txt\n```\n\n## Command Options\n\n| Option | Description |\n|--------|-------------|\n| `-n, --numeric` | Compare according to string numerical value |\n| `-r, --reverse` | Reverse the result of comparisons |\n| `-h, --help` | Show help message and exit |\n\n## Examples\n\n### Basic Sorting\n\n```bash\n# Alphabetical sort\ncat names.txt | sort\n\n# Sort and save to file\nsort input.txt > sorted.txt\n```\n\n### Numeric Sorting\n\n```bash\n# Sort numbers correctly\necho -e \"100\\n20\\n3\\n1000\" | sort -n\n# Output:\n# 3\n# 20\n# 100\n# 1000\n```\n\n### Reverse Sorting\n\n```bash\n# Descending order\necho -e \"a\\nc\\nb\" | sort -r\n# Output:\n# c\n# b\n# a\n```\n\n### Combined with Other Tools\n\n```bash\n# Sort and remove duplicates\nsort file.txt | uniq\n\n# Sort CSV by second column\ncut -d',' -f2 data.csv | sort -n\n\n# Count and sort word frequency\ncat text.txt | tr ' ' '\\n' | sort | uniq -c | sort -rn\n```\n\n## Development\n\n### Setup Environment\n\n```bash\n# Create virtual environment\npython3 -m venv test\nsource test/bin/activate # On Windows: venv\\Scripts\\activate\n\n# Install in development mode\npip install -e .\n```\n\n### Building Docker Image\n\n```bash\ndocker build -t nastya-sort .\ndocker run nastya-sort --help\n```\n\n### Testing\n\n```bash\n# Test basic sorting\necho -e \"c\\na\\nb\" | sort\n\n# Test numeric sorting\necho -e \"10\\n2\\n1\" | sort -n\n\n# Test with Docker\necho -e \"3\\n1\\n2\" | docker run -i nastya-sort -n\n```\n\n\n## Project Structure\n\n```\nnastya-sort/\n\u251c\u2500\u2500 nastya_sort/\n\u2502 \u251c\u2500\u2500 __init__.py # Package version\n\u2502 \u2514\u2500\u2500 cli.py # CLI implementation\n\u251c\u2500\u2500 .github/\n\u2502 \u2514\u2500\u2500 workflows/\n\u2502 \u2514\u2500\u2500 docker-publish.yml # CI/CD pipeline\n\u251c\u2500\u2500 Dockerfile # Docker image definition\n\u251c\u2500\u2500 setup.py # Package configuration\n\u251c\u2500\u2500 README.md # This file\n\u2514\u2500\u2500 .gitignore # Git ignore rules\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Simple sort utility implemented in Python with Click",
"version": "0.2.6",
"project_urls": {
"Homepage": "https://github.com/Nastia2004/nastya-sort-lnu"
},
"split_keywords": [
"sort",
"cli",
"utility",
"unix"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "b30dbd367d0b8ef5193a45d1b3ebd7626223777c2774ed1aa8fc01a53cd3dde7",
"md5": "08cc780eb8700edbeb929b4fd710e505",
"sha256": "32690f60847e453eacc46ad56d08c42e5d86c09c4efd13e0cc0cafb4bf1fc3f9"
},
"downloads": -1,
"filename": "nastya_sort_lnu-0.2.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "08cc780eb8700edbeb929b4fd710e505",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 4627,
"upload_time": "2025-10-20T14:33:33",
"upload_time_iso_8601": "2025-10-20T14:33:33.870434Z",
"url": "https://files.pythonhosted.org/packages/b3/0d/bd367d0b8ef5193a45d1b3ebd7626223777c2774ed1aa8fc01a53cd3dde7/nastya_sort_lnu-0.2.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "5c18ccd67f2062e2737b57071392e1ff1579da75503df65548aa4595d87f190c",
"md5": "6c5e5e81e7761832480f214f65b4a112",
"sha256": "c93aad06ed81f62330f5b0261996b3bad679bb81b8f52df7da95a8482c6950ab"
},
"downloads": -1,
"filename": "nastya_sort_lnu-0.2.6.tar.gz",
"has_sig": false,
"md5_digest": "6c5e5e81e7761832480f214f65b4a112",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 4506,
"upload_time": "2025-10-20T14:33:34",
"upload_time_iso_8601": "2025-10-20T14:33:34.807899Z",
"url": "https://files.pythonhosted.org/packages/5c/18/ccd67f2062e2737b57071392e1ff1579da75503df65548aa4595d87f190c/nastya_sort_lnu-0.2.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-20 14:33:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Nastia2004",
"github_project": "nastya-sort-lnu",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "nastya-sort-lnu"
}