Conversation
The previous code was only able to receive integers but crashes when you included string and float. Now the new changes receives strings, floats, and integers without crashing.
…ort them. The code receives integers, strings, and floats. After that it sort them in this order: 1. Numbers are sorted first, followed by alphabets. 2. Integers and floats are sorted according to their magnitude. 3. Strings are sorted in alphabetical order.
I reviewed and revised the changes from the previous commits and made sure that they follow the CONTRIBUTING.md guidelines. The revisions I made include: 1.Correcting and expanding doctests. 2. Adding missing type hints and docstrings. 3. Handling invalid input with ValueError. 4. Improving variable naming and code readability. 5. Cleaning up formatting and spacing. 6. Maintaining the original patience sort implementation and the added mixed integer, float, and string functionality.
Member
|
Please rebase to the current master branch to fix git merge conflicts. |
cclauss
reviewed
Oct 2, 2026
| user_input = input("Enter numbers separated by a comma:\n").strip() | ||
| unsorted = [int(item) for item in user_input.split(",")] | ||
| print(patience_sort(unsorted)) | ||
| user_input: str| int|float = input("Enter integers, floats, and strings separated by commas:\n").strip() |
Member
There was a problem hiding this comment.
input() always returns a string. It never returns an int or a float.
We do not need type hints everywhere. Python can figure out what the types are on its own.
We only need type hints on function parameters and function returns.
for more information, see https://pre-commit.ci
Member
|
This algorithm was already modified to match the approach discussed in: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your change
The changes I made include:
1.I updated the existing patience_sort() function and its documentation.
2. I added mixed_patience_sort() to support sorting collections containing integers, floats, and strings.
3. I added convert_item() to convert user input into integers, floats, or strings.
4. I updated the manual input section to accept integers, floats, and strings.
5. I added comments to make the main parts of the implementation easier to understand.
6. I added examples for the new functionality.
7. I kept the original patience sort algorithm as the foundation of the implementation.
Checklist