]> git.ipfire.org Git - network.git/commitdiff
Remove sorting algorithm implemented in shell code.
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 27 May 2012 12:31:56 +0000 (12:31 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 27 May 2012 12:31:56 +0000 (12:31 +0000)
Because of the recently remove feature of having an extra
/usr partition, we could not use /usr/bin/sort.

functions.util

index f990362f7e2b351336de6d7af9de669e9c271ae0..68e5782368378df6bb96d09d57716c5c57ffe2e5 100644 (file)
@@ -37,30 +37,11 @@ function warning_log() {
        log WARNING "$@"
 }
 
-# This function does not exist because we cannot use /usr/bin/sort.
-# It implements some kind of bubble sort which is generally very slow
-# but we only have to sort very small data.
 function listsort() {
-       local list=($@)
-       local list_prev
-
        local i
-       local j
-       local var
-       while [ "${list[*]}" != "${list_prev}" ]; do
-               list_prev="${list[*]}"
-               for j in $(seq 1 ${#list[*]}); do
-                       [ ${j} -ge ${#list[*]} ] && continue
-                       i=$(( ${j} - 1 ))
-                       if [[ "${list[${j}]}" < "${list[${i}]}" ]]; then
-                               var="${list[${i}]}"
-                               list[${i}]="${list[${j}]}"
-                               list[${j}]="${var}"
-                       fi
-               done
-       done
-
-       echo "${list[*]}"
+       for i in $@; do
+               echo "${1}"
+       done | sort | tr '\n' ' '
 }
 
 function listmatch() {