Skip to content

Shell sort #37

Open
Open

Activity

make-github-pseudonymous-again

make-github-pseudonymous-again commented on Jun 25, 2015

@make-github-pseudonymous-again
OwnerAuthor

Example in PHP

function shellSort(&$a) {
    $n = count($a);
    $d = floor($n / 2);
    while ($d > 0) {
        for ($i = 0; $i < ($n - $d); $i++) {
            $j = $i;
            while ($j >= 0 && $a[$j] > $a[$j + $d]) {
                list($a[$j], $a[$j + $d]) = array($a[$j + $d], $a[$j]);
                $j--;
            }
        }
        $d = floor($d / 2);
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @make-github-pseudonymous-again

      Issue actions

        Shell sort · Issue #37 · make-github-pseudonymous-again/js-sorting