-44,10 +46,29 |
@unsorted; |
}}} |
|
== # Guttman Rosler Transform == |
한술 더 떠서, ST에서 무수한 익명 배열을 만드는 오버헤드를 피하고, sort에서 기본으로 제공하는 정렬 알고리즘을 사용하게 변환할 수 있다.<footnote([http://www.perlmonks.org/?node_id=145659 Advanced Sorting - GRT - Guttman Rosler Transform -- Advanced Sorting - GRT - Guttman Rosler Transform])> |
|
{{{#!vim perl |
my @words=qw(The time has come the Walrus said to speak of many things); |
## 위 리스트를, 각 단어 내의 "e"또는 "E"의 갯수에 따라 정렬하는 경우 |
|
# ST |
my @sorted=map { pop @$_ } |
sort{ $a->[0] <=> $b->[0] || |
$a->[1] cmp $b->[1] } |
map { [tr/eE/eE/,$_] } @words; |
|
# GRT |
my @sorted=map { substr($_,4) } |
sort |
map { pack("LA*",tr/eE/eE/,$_) } @words; |
}}} |
|
<div class="comments"> |
<longcomments(100)> |
---- |
<trackbackreceived> |
|
</div> |
---- |
[[컴퓨터분류]] |