Skip to content

Instantly share code, notes, and snippets.

@alvinmatias69
Last active December 31, 2019 03:44
Show Gist options
  • Save alvinmatias69/6eba6690ac2b0f52c05190fa14253ae4 to your computer and use it in GitHub Desktop.
Save alvinmatias69/6eba6690ac2b0f52c05190fa14253ae4 to your computer and use it in GitHub Desktop.
High performance sort that will remove every inappropriate element to create sorted ascending list. Always operate in O(n)
#!/bin/sh
TEMP=-9999999
for item in "$@"
do
if [ "$TEMP" -lt "$item" ]
then
printf "%s " "$item"
fi
TEMP=$item
done
echo
# ./orba_sort.sh 2 3 1 5 6 2 1 8
# 2 3 5 6 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment