A quick sort of shell script programming algorithm

Source: Internet
Author: User
#!/bin/bash#shell implementation of the fast sequencing of script programming (with the idea of a meta-point at the far right) a= (8 5 3 2 for 4 1 2 3 + 9 for 8 6) temp=buff= #交换函数swap () {buff=${a[$1]}a[$1]= ${a[$2]}a[$2]= $buff}fun () {i=$ ($1-1) j=$1temp=${a[$2]}if test $1-ge; Thenreturn 2 Fiwhile [$j-le $];d owhile [$j- Lt $2-a ${a[$j]}-gt $temp];d o j=$ (($j + 1)) donei=$ (($i + 1)) Swap $i $jj =$ (($j + 1)) Done Fun 0 $ (($i-1)) Fun $ (($i +2)) $2}fun 0 15for ((i=0;i<16;i++)) {echo-n ${a[$i]} ""}echoexit 0

A quick sort of shell script programming algorithm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.