2016-08-18 4 views
0

집합을 정렬 된 배열로 변환하는 방법을 찾고있었습니다.정렬 된 배열 perl로 집합 가져 오기

나는 해결책을 찾았지만 조금 rediculous 것 같다

use Set::Scalar; 
Set::Scalar->as_string_callback(sub{join("\n", sort $_[0]->elements)}); 
#above formats print so that a line is added between each element 
... #assume things are added to the set in this code 
my @arr = split("\n", "$set"); #array contains each sorted element of the set 

내 유일한 문제는 내 눈이이 일의 빠른/메모리 효율적인 방법하지 않아야한다는 것입니다. 조언이 있으면 알려주세요. 미리 감사드립니다.

답변