# 挿入ソート インサーションソート Insertion Sort # 引数 値 (\@Price) # 戻り値 インサーションソート (@InsertionSort) sub SELECTIONSORT{ my ($Price) = @_; my @InsertionSort = @$Price; my $Count = @$Price - 1; # 配列数の確認 if($Count < 0){ return 0; } # 昇順ソート for(my $i = 0; ($i + 1) <= $Count; $i++){ for(my $j = ($i + 1); $j > 0; $j--){ if($InsertionSort[$j - 1] > $InsertionSort[$j]){ # 挿入ソート インサーションソート Insertion Sort ($InsertionSort[$j], $InsertionSort[$j - 1]) = ($InsertionSort[$j - 1], $InsertionSort[$j]); }else { last; } } } return @InsertionSort; }