Skip to content

lasnelus/GSort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

Gsort Algorithm

Gsort is a humorous and intentionally broken sorting algorithm inspired by the "Stalin Sort" — a joke algorithm where any data that doesn't fit the desired order is simply discarded.


What Is This?

Gsort is based on a sarcastic interpretation of sorting:

"I stop reading after the first error." — A math teacher.

This algorithm walks through a list and stops the moment a number fails to be bigger than the previous. It then returns only the part of the list that was "in line".


How It Works

  • Start from the first element in the list.
  • Compare each number to the next one using a comparison function.
  • If the next number is bigger, continue.
  • If it's equal to or smaller, stop immediately and return what you've seen so far.

Functions

is_smaller_than(a: float, b: float) -> bool

Returns True if b is greater than a.
This is the comparison logic Gsort uses.

Gsort(list: list) -> list

Implements the Gsort algorithm:

  • Iterates over the list.
  • Keeps numbers only as long as the next is greater.
  • As soon as one number decrease, the function stops and returns what it has.

Example

from gsort import Gsort

Gsort([9, 8, 7, 10, 5, 1])
# Output: [9]

Gsort([3, 4, 5, 2, 1])
# Output: [3, 4, 5]

Do Not Use This Seriously

This is not a real sorting algorithm. It’s a parody of poor logic and overly strict systems. It doesn't preserve data, order, or sanity.

Use Cases

  • Teaching what not to do in algorithms.

  • Making fun of bad logic in code reviews.

  • Gag presentations at developer meetups.

  • Trolling your colleagues with "new" sorting ideas.

License

WTFPL – Do What the F*ck You Want to Public License.

Author

Crafted with Python and sarcasm by someone who enjoys algorithm humor. @lasnelus

wakatime

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages