{"id":24614,"library":"sort-lines","title":"sort-lines","description":"A simple command-line tool and Python library to alphabetically sort lines in files. Version 0.3.0 supports Python >=3.9. Maintenance is infrequent.","status":"active","version":"0.3.0","language":"python","source_language":"en","source_url":"https://github.com/samueljsb/sort-lines","tags":["sorting","lines","file","text","utility"],"install":[{"cmd":"pip install sort-lines","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"sort_lines is a function, not a module. Importing the package directly gives you the module, not the function.","wrong":"import sort_lines","symbol":"sort_lines","correct":"from sort_lines import sort_lines"}],"quickstart":{"code":"from sort_lines import sort_lines\n\n# In-place sort lines in a file\nsort_lines('path/to/file.txt', in_place=True)\n\n# Or sort and return as string\nsorted_text = sort_lines('path/to/file.txt', in_place=False)\nprint(sorted_text)","lang":"python","description":"Sort lines in a file. Use in_place=True to modify the file directly, or False to return the sorted text."},"warnings":[{"fix":"Consider using alternative tools or chunking if dealing with large files.","message":"The sort_lines function reads the entire file into memory. For very large files, this may cause memory issues.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure your file ends with a newline or handle manually after sorting.","message":"The library does not preserve trailing newlines behavior uniformly across platforms. Sorting may add or remove trailing newline depending on input.","severity":"gotcha","affected_versions":"all"},{"fix":"Preprocess lines (e.g., lowercasing) before passing to sort_lines if case-insensitive sort is needed.","message":"There is no support for case-insensitive sorting or custom sort keys. Sorting is always lexicographic (case-sensitive).","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use: from sort_lines import sort_lines","cause":"Importing the package as 'import sort_lines' instead of importing the function.","error":"AttributeError: module 'sort_lines' has no attribute 'sort_lines'"},{"fix":"Check that the file path is correct and the file exists before calling sort_lines.","cause":"The file path provided does not exist. sort_lines does not create files, only modifies existing ones.","error":"FileNotFoundError: [Errno 2] No such file or directory: '...'"},{"fix":"Provide the filename as the first argument: sort_lines('file.txt')","cause":"Calling sort_lines without the filename argument.","error":"TypeError: sort_lines() missing 1 required positional argument: 'filename'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}