Skip to content

Instantly share code, notes, and snippets.

@chantra
Created October 7, 2022 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chantra/3c06ff7722568c928b79e3ba5b8ae5a7 to your computer and use it in GitHub Desktop.
Save chantra/3c06ff7722568c928b79e3ba5b8ae5a7 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
declare -a myarray=(a z d "e f")
readarray -t test_names < \
<(printf '%s\0' "${myarray[@]}" "$@" | sort -z -u | xargs -0n1)
for test_name in "${test_names[@]}"
do
echo $test_name
done
@chantra
Copy link
Author

chantra commented Oct 7, 2022

/tmp/sorting.sh a d c z        
a
c
d
e f
z

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment