- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 342
 
Add Postman Sort (LSD Radix Sort) in R #243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds an implementation of Postman Sort (LSD Radix Sort) for sorting non-negative integers in R. The algorithm processes digits from least to most significant using stable counting sort, following the typical base-10 radix sort pattern.
Key Changes:
- New implementation of LSD Radix Sort with digit-by-digit counting sort
 - Input validation for numeric vectors, non-negative integers only
 - Helper functions for finding maximum value and performing counting sort per digit
 
| # For safety, coerce to integer-like values | ||
| if (any(elements.vec != floor(elements.vec))) stop("postman.sort: values must be integers") | ||
| 
               | 
          ||
| get.max <- function(a) max(a) | 
    
      
    
      Copilot
AI
    
    
    
      Oct 23, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The get.max helper function is unnecessary and reduces readability. It simply wraps the built-in max() function without adding any value. Consider using max() directly on line 47 instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check
| # For safety, coerce to integer-like values | ||
| if (any(elements.vec != floor(elements.vec))) stop("postman.sort: values must be integers") | ||
| 
               | 
          ||
| get.max <- function(a) max(a) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check
This implementation provides decimal LSD (Least Significant Digit) Radix Sort in R.
It sorts non-negative integers by repeatedly applying a stable counting sort to each digit, from the least significant to the most significant.
Overview
Features
exp) iterativelyComplexity
n= number of elements,d= number of digits in the maximum element,k= radix/base (10 here)