How can I get unique values from an array in Bash?

printf "%s\n" "${IDS[@]}" | sort -u

Example:

~> IDS=( "aa" "ab" "aa" "ac" "aa" "ad" )~> echo  "${IDS[@]}"aa ab aa ac aa ad~>~> printf "%s\n" "${IDS[@]}" | sort -uaaabacad~> UNIQ_IDS=($(printf "%s\n" "${IDS[@]}" | sort -u))~> echo "${UNIQ_IDS[@]}"aa ab ac ad~>