www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Multisort

reply dsimcha <dsimcha yahoo.com> writes:
I've been working on implementing some statistics functions in D, and noticed
that it would be nice if a multisort function were in Phobos.  Such a function
would take N arrays in and sort them by the first one.  The common way to
handle something like this seems to be to make a struct with the fields, make
opCmp point to whatever field you want to sort by, and then use a regular
sorting algorithm.  This is slow and a pain.  I've implemented a few different
multisort functions, along with documentation and unit testing, and would like
to contribute them to Phobos.  I've attached the source file and the Ddoc
documentation.
begin 644 phobosSort.d
M+R\ 5W)I='1E;B!I;B!T:&4 1"!P<F]G<F%M;6EN9R!L86YG=6%G92X-" T*
M+RH-"B`J("!#;W!Y<FEG:'0 *$,I(#(P,#  8GD 1&%V:60 4VEM8VAA+ T*
M("H-"B`J("!4:&ES('-O9G1W87)E(&ES('!R;W9I9&5D("=A<RUI<R<L('=I
M=&AO=70 86YY(&5X<')E<W, ;W( :6UP;&EE9`T*("H ('=A<G)A;G1Y+B!)
M;B!N;R!E=F5N="!W:6QL('1H92!A=71H;W)S(&)E(&AE;&0 ;&EA8FQE(&9O
M<B!A;GD 9&%M86=E<PT*("H (&%R:7-I;F< 9G)O;2!T:&4 =7-E(&]F('1H
M:7, <V]F='=A<F4N#0H * T*("H (%!E<FUI<W-I;VX :7, 9W)A;G1E9"!T
M;R!A;GEO;F4 =&\ =7-E('1H:7, <V]F='=A<F4 9F]R(&%N>2!P=7)P;W-E
M+`T*("H (&EN8VQU9&EN9R!C;VUM97)C:6%L(&%P<&QI8V%T:6]N<RP 86YD
M('1O(&%L=&5R(&ET(&%N9"!R961I<W1R:6)U=&4 :70-"B`J("!F<F5E;'DL
M('-U8FIE8W0 =&\ =&AE(&9O;&QO=VEN9R!R97-T<FEC=&EO;G,Z#0H * T*
M("H (&\ (%1H92!O<FEG:6X ;V8 =&AI<R!S;V9T=V%R92!M=7-T(&YO="!B
M92!M:7-R97!R97-E;G1E9#L >6]U(&UU<W0 ;F]T#0H *B` ("` 8VQA:6T 
M=&AA="!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H ("` ("` ("` ("!F;W)E86-H*&%R<F%Y.R!D871A
M*2!S=V%P*&%R<F%Y6VE=+"!A<G)A>5MS=V%P26YD97A=*3L-"B` ("` ("` 
M("` ('-W87!);F1E>"LK.PT*("` ("` ("!]#0H ("` ?0T*("` (&9O<F5A
M8V H:2P 87)R87D[(&1A=&$I('L-"B` ("` ("` <W=A<"AA<G)A>5LD+3%=
M+"!A<G)A>5MS=V%P26YD97A=*3L-"B` ("` ("` ;&5S<UMI72`](&%R<F%Y
M6S`N+G-W87!);F1E>%T[#0H ("` ("` (&=R96%T97);:5T /2!A<G)A>5MS
M=V%P26YD97  *R`Q+BXD73L-"B` ("!]#0H ("` <7-O<G0H;&5S<RD[#0H 
M("` <7-O<G0H9W)E871E<BD[#0H ("` <F5T=7)N(&1A=&%;,%T[("`O+TUA
M:V4 =&AI<R!F=6YC=&EO;B!L:6ME(")N;W)M86PB('%S;W)T(&EF(&1A=&$N
M;&5N9W1H(&ES(&]N92X-"GT-" T*+RHJ4W1A8FQE('9E<G-I;VX ;V8 <7-O
M<G0H*2!F=6YC=&EO;BX ($1O97, ;F]T('-O<G0 :6X <&QA8V4L(&%N9`T*
M("H :7, 86)O=70 ,34E('-L;W=E<B!T:&%N('5N<W1A8FQE('9E<G-I;VXL
M('-O('5S92!O;FQY('=H96X ;F5C97-S87)Y+ T*("H 06QS;RP <&5R9F]R
M;6%N8V4 :7, 3RA.7C(I(&]N('!R92US;W)T960 87)R87ES+"!B96-A=7-E
M(&-H;V]S:6YG(&%N#0H *B!I;G1E;&QI9V5N="!P:79O="!I<R!D:69F:6-U
M;'0 ;W( :6UP;W-S:6)L92!I;B!A('-T86)L92!Q<V]R="X-"B`J('-T86)L
M95%S;W)T(&-R96%T97, =&5M<"!V87)I86)L97, 86YD(&9O<G=A<F1S(&%L
M;"!D871A('1O#0H *B!S=&%B;&51<V]R=$)A8VM%;F0N("!(;W=E=F5R+"!S
M=&%B;&51<V]R=$)A8VM%;F0 :7, 8V%L;&%B;&4 9&ER96-T;'DL#0H *B!I
M;B!C87-E('1H92!U<V5R('=A;G1S('1O(')E8WEC;&4 <')E+6%L;&]C871E
M9"!T96UP('-P86-E+B`J+PT*#0I46S!=('-T86)L95%S;W)T*%0N+BXI*%0 
M9&%T82D >PT*("` ('1Y<&5O9BAD871A*2!T96UP.PT*("` (&9O<F5A8V H
M:2P 87)R87D[('1E;7`I('L-"B` ("` ("` =&5M<%MI72`](&YE=U9O:60A
M*'1Y<&5O9BAD871A6VE=6S!=*2DH9&%T85MI72YL96YG=& I.PT*("` ('T-
M"B` ("!S=&%B;&51<V]R=$)A8VM%;F0H9&%T82P =&5M<"D[#0H ("` 9F]R
M96%C:"AI+"!A<G)A>3L =&5M<"D >PT*("` ("` ("!D96QE=&4 =&5M<%MI
M73L ("\O1&\ =&AS(&UA;G5A;&QY('-I;F-E($=#('-O;65T:6UM97, 9F%I
M;', ;VX ;&%R9V4 87)R87ES+ T*("` ('T-"B` ("!R971U<FX 9&%T85LP
M73L-"GT-" T*5%LP72!S=&%B;&51<V]R=$)A8VM%;F0H5"XN+BDH5"!D871A
M26XI('L ("\O07-S=6UE<R!F:7)S="!H86QF(&]F(&EN<'5T(&ES(&1A=&$L
M('-E8V]N9"!H86QF(&ES('1E;7`N#0H ("` 875T;R!D871A(#T 9&%T84EN
M6S`N+F1A=&%);BYL96YG=& O,ET[#0H ("` 875T;R!T96UP(#T 9&%T84EN
M6V1A=&%);BYL96YG=& O,BXN)%T[#0H ("` 87-S97)T*&1A=&%;,%TN<'1R
M("$]('1E;7!;,%TN<'1R*3L-"B` ("!I9BAD871A6S!=+FQE;F=T:"`\(# I
M('L-"B` ("` ("` ('-T86)L95-E;&5C=&EO;E-O<G0H9&%T82D[#0H ("` 
M("` ("!R971U<FX 9&%T85LP73L-"B` ("!]#0H ("` ='EP96]F*&1A=&$I
M(&QE<W,L(&=R96%T97(L(&QE<W-496UP+"!G<F5A=&5R5&5M<#L-"B` ("!S
M:7IE7W0 :6YD97  /2`P.PT*("` (&9O<F5A8V H:3L ,"XN9&%T85LP72YL
M96YG=&  +2`Q*2![#0H ("` ("` (&EF*&1A=&%;,%U;:5T /#T 9&%T85LP
M75LD+3%=*2![#0H ("` ("` ("` ("!F;W)E86-H*'1I+"!A<G)A>3L 9&%T
M82D =&5M<%MT:5U;:6YD97A=(#T 87)R87E;:5T[#0H ("` ("` ("` ("!I
M;F1E>"LK.PT*("` ("` ("!]#0H ("` ?0T*("` (&9O<F5A8V H=&DL(&%R
M<F%Y.R!D871A*2!T96UP6W1I75MI;F1E>%T /2!A<G)A>5LD+3%=.PT*("` 
M('-I>F5?="!M:60 /2!I;F1E>#L-"B` ("!I;F1E>"LK.PT*("` (&9O<F5A
M8V H:3L ,"XN9&%T85LP72YL96YG=&  +2`Q*2![#0H ("` ("` (&EF*&1A
M=&%;,%U;:5T /B!D871A6S!=6R0M,5TI('L-"B` ("` ("` ("` (&9O<F5A
M8V H=&DL(&%R<F%Y.R!D871A*2!T96UP6W1I75MI;F1E>%T /2!A<G)A>5MI
M73L-"B` ("` ("` ("` (&EN9&5X*RL[#0H ("` ("` ('T-"B` ("!]#0H 
M("` 9F]R96%C:"AI+"!A<G)A>3L =&5M<"D >PT*("` ("` ("!D871A6VE=
M6S`N+B1=(#T 87)R87E;,"XN)%T[#0H ("` ?0T*("` (&9O<F5A8V H:2P 
M87)R87D[(&1A=&$I('L-"B` ("` ("` ;&5S<UMI72`](&%R<F%Y6S`N+FUI
M9%T[#0H ("` ("` (&=R96%T97);:5T /2!A<G)A>5MM:60 *R`Q+BXD73L-
M"B` ("` ("` ;&5S<U1E;7!;:5T /2!T96UP6VE=6S`N+FUI9%T[#0H ("` 
M("` (&=R96%T97)496UP6VE=(#T =&5M<%MI75MM:60 *R`Q+BXD73L-"B` 
M("!]#0H ("` <W1A8FQE47-O<G1"86-K16YD*&QE<W,L(&QE<W-496UP*3L-
M"B` ("!S=&%B;&51<V]R=$)A8VM%;F0H9W)E871E<BP 9W)E871E<E1E;7`I
M.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[#0H ("` ("` ('5L;VYG*B!S=V%P0V]U;G0 /2!D871A6R0M
M,5T[#0H ("` ?2!E;'-E('L-"B` ("` ("` :6YV87)I86YT('5I;G0 9&P 
M/2!D871A+FQE;F=T:#L-"B` ("` ("` =6QO;F< 9'5M;7D /2!V;VED.R` 
M+R]4:&ES(&ES(&$ 9'5M;7D =F%R:6%B;&4N("!)="!D;V5S;B=T(&YE960 
M=&\ 8F4 :6YI=&EA;&EZ960N#0H ("` ("` ('5L;VYG*B!S=V%P0V]U;G0 
M/2`F9'5M;7D[("`O+TUA:V5S('1H:6YG<R!A(&QO="!E87-I97( :68 22!U
M<V4 82!D=6UM>2!S=V%P8V]U;G0 =F%R:6%B;&4 :6YS=&%E9"!O9B!W<FET
M:6YG(&$ =VAO;&4 8G5N8V  ;V8 <W1A=&EC(&EF<RX-"B` ("!]#0H ("` 
M='EP96]F*&1A=&%;,"XN9&Q=*2!T96UP.PT*("` (&9O<F5A8V H:2P 87)R
M87D[('1E;7`I('1E;7!;:5T /2!N97=6;VED(2AT>7!E;V8H9&%T85MI75LP
M72DI*&1A=&%;:5TN;&5N9W1H*3L-"B` ("!46S!=(&]U='!U="`](&UE<F=E
M4V]R=$)A8VM%;F0H9&%T85LP+BYD;%TL('1E;7`L('-W87!#;W5N="D[#0H 
M("` 9F]R96%C:"AT:2P 87)R87D[('1E;7`I(&1E;&5T92!T96UP6W1I73L-
M"B` ("!R971U<FX ;W5T<'5T.PT*?0T*#0I46S!=(&UE<F=E4V]R=$)A8VM%
M;F0H5"XN+BDH5"!D871A26XI('L-"B` ("!A=71O(&1A=&$ /2!D871A26Y;
M,"XN9&%T84EN+FQE;F=T:"\R73L-"B` ("!A=71O('1E;7` /2!D871A26Y;
M9&%T84EN+FQE;F=T:"\R+BXD+3%=.PT*("` ('5L;VYG*B!S=V%P0V]U;G0 
M/2!D871A26Y;)"TQ73L-"B` ("!I9BAD871A6S!=+FQE;F=T:"`\(#(I('L-
M"B` ("` ("` <F5T=7)N('-T86)L95-E;&5C=&EO;E-O<G0H9&%T82P <W=A
M<$-O=6YT*3L-"B` ("!]#0H ("` <VEZ95]T(&AA;&8 /2!D871A6S!=+FQE
M;F=T:"`O(#([#0H ("` ='EP96]F*&1A=&$I(&QE9G0L(')I9VAT+"!T96UP
M3&5F="P =&5M<%)I9VAT.PT*("` (&9O<F5A8V H=&DL(&%R<F%Y.R!D871A
M*2![#0H ("` ("` (&QE9G1;=&E=(#T 87)R87E;,"XN:&%L9ET[#0H ("` 
M("` (')I9VAT6W1I72`](&%R<F%Y6VAA;&8N+B1=.PT*("` ("` ("!T96UP
M3&5F=%MT:5T /2!T96UP6W1I75LP+BYH86QF73L-"B` ("` ("` =&5M<%)I
M9VAT6W1I72`]('1E;7!;=&E=6VAA;&8N+B1=.PT*("` ('T-"B` ("!M97)G
M95-O<G1"86-K16YD*&QE9G0L('1E;7!,969T+"!S=V%P0V]U;G0I.PT*("` 
M(&UE<F=E4V]R=$)A8VM%;F0H<FEG:'0L('1E;7!2:6=H="P <W=A<$-O=6YT
M*3L-"B` ("!M97)G92AL969T+"!R:6=H="P =&5M<"P <W=A<$-O=6YT*3L-
M"B` ("!F;W)E86-H*'1I+"!A<G)A>3L =&5M<"D >PT*("` ("` ("!D871A
M6W1I75LP+BXD72`]('1E;7!;=&E=6S`N+B1=.PT*("` ('T-"B` ("!R971U
M<FX 9&%T85LP73L-"GT-" T*+R\O365R9V4 9G5N8W1I;VX 9F]R(&UE<F=E
M('-O<G0N#0IV;VED(&UE<F=E*%0N+BXI*%0 9&%T82D >PT*("` ('5L;VYG
M*B!S=V%P0V]U;G0 /2!D871A6R0M,5T[#0H ("` :6YV87)I86YT('5I;G0 
M9&P /2!D871A+FQE;F=T:"`M(#$[("`O+U)E86P ;&5N9W1H(&%F=&5R(')E
M;6]V:6YG('-W87!#;W5N=#L-"B` ("!S=&%T:6, 87-S97)T*&1L("4 ,R`]
M/2`P*3L ("\O069T97( =&%K:6YG(&]U="!S=V%P8V]U;G0L(&YU;6)E<B!O
M9B!A<F=U;65N=', <VAO=6QD(&)E(&1I=FES:6)L92!B>2!T:')E92X-"B` 
M("!A=71O(&QE9G0 /2!D871A6S`N+F1L+S-=.PT*("` (&%U=&\ <FEG:'0 
M/2!D871A6V1L+S,N+F1L*C(O,UT[#0H ("` 875T;R!R97-U;'0 /2!D871A
M6V1L*C(O,RXN9&Q=.PT*("` ('-T871I8R!A<W-E<G0H;&5F="YL96YG=&  
M/3T <FEG:'0N;&5N9W1H("8F(')I9VAT+FQE;F=T:"`]/2!R97-U;'0N;&5N
M9W1H*3L-"B` ("!S:7IE7W0 :2`](')E<W5L=%LP72YL96YG=&  +2`Q.PT*
M("` ("\O=W)I=&5F*&QE9G0L(")<="(L(')I9VAT+"`B7'0B+"`B(#X^("( 
M*3L-"B` ("!W:&EL92AL969T6S!=+FQE;F=T:"`F)B!R:6=H=%LP72YL96YG
M=& I('L-"B` ("` ("` :68H<FEG:'1;,%U;)"`M(#%=(#X](&QE9G1;,%U;
M)"`M(#%=*2![#0H ("` ("` ("` ("!F;W)E86-H*'1I+"!A<G)A>3L <F5S
M=6QT*2![#0H ("` ("` ("` ("` ("` <F5S=6QT6W1I75MI72`](')I9VAT
M6W1I75LD+3%=.PT*("` ("` ("` ("` ("` (')I9VAT6W1I72YL96YG=&  
M/2!R:6=H=%MT:5TN;&5N9W1H("T ,3L-"B` ("` ("` ("` ('T-"B` ("` 
M("` ?2!E;'-E('L-"B` ("` ("` ("` ("IS=V%P0V]U;G0 *ST <FEG:'1;
M,%TN;&5N9W1H.PT*("` ("` ("` ("` 9F]R96%C:"AT:2P 87)R87D[(')E
M<W5L="D >PT*("` ("` ("` ("` ("` (')E<W5L=%MT:5U;:5T /2!L969T
M6W1I75LD+3%=.PT*("` ("` ("` ("` ("` (&QE9G1;=&E=+FQE;F=T:"`]
M(&QE9G1;=&E=+FQE;F=T:"`M(#$[#0H ("` ("` ("` ("!]#0H ("` ("` 
M('T-"B` ("` ("` :2TM.PT*("` ('T-"B` ("!I9BAR:6=H=%LP72YL96YG
M=& I('L-"B` ("` ("` 9F]R96%C:"AT:2P 87)R87D[(')E<W5L="D >PT*
M("` ("` ("` ("` <F5S=6QT6W1I75LP+BYR:6=H=%MT:5TN;&5N9W1H72`]
M(')I9VAT6W1I73L-"B` ("` ("` ?0T*("` ('T 96QS92![#0H ("` ("` 
M(&9O<F5A8V H=&DL(&%R<F%Y.R!R97-U;'0I('L-"B` ("` ("` ("` (')E
M<W5L=%MT:5U;,"XN;&5F=%MT:5TN;&5N9W1H72`](&QE9G1;=&E=.PT*("` 
M("` ("!]#0H ("` ?0T*("` +R\ =W)I=&5F;&XH<F5S=6QT*3L-"GT-" T*
M+RHJ0G5B8FQE(&UU;'1I<V]R="!F=6YC=&EO;BX (%5S969U;"!O;FQY(&)E
M8V%U<V4 :70G<R!E87-Y('1O(&EM<&QE;65N=`T*("H 86YD('1E<W0 ;W1H
M97( <V]R=&EN9R!F=6YC=&EO;G, 86=A:6YS="X ($-O=6YT<R!S=V%P<R!I
M9B!L87-T#0H *B!A<F=U;65N="!I<R!A('5L;VYG*BX *B\-" T*5%LP72!B
M=6)B;&53;W)T*%0N+BXI*%0 9&%T82D >PT*("` ("\O268 ;&%S="!A<F=U
M;65N="!I<R!A('!O:6YT97( =&\ 86X :6YT96=E<B!T>7!E+"!I;F-R96UE
M;G1S('1H:7, :6YT96=E<B!A<R!A('-W87!#;W5N="!V87)I86)L92X ($EF
M(&ET(&ES(&%N>71H:6YG#0H ("` +R]O=&AE<B!T:&%N(&%N(&%R<F%Y(&]R
M(&$ <&]I;G1E<B!T;R!A;B!I;G1E9V5R+"!U;F1E9FEN960 8F5H879I;W(N
M#0H ("` <W1A=&EC(&EF*"%I<T%R<F%Y(2AT>7!E;V8H9&%T85LD+3%=*2DI
M(&EN=F%R:6%N="!U:6YT(&1L(#T 9&%T82YL96YG=&  +2`Q.PT*("` (&5L
M<V4 :6YV87)I86YT('5I;G0 9&P /2!D871A+FQE;F=T:#L-"B` ("!I9BAD
M871A6S!=+FQE;F=T:"`\(#(I(')E='5R;B!D871A6S!=.PT*("` ('5I;G0 
M<W=A<$5X96-U=&5D(#T =F]I9#L-"B` ("!F;W)E86-H*&D[(#`N+F1A=&%;
M,%TN;&5N9W1H*2![#0H ("` ("` ('-W87!%>&5C=71E9"`](#`[#0H ("` 
M("` (&9O<F5A8V H:CL ,2XN9&%T85LP72YL96YG=& I('L-"B` ("` ("` 
M("` (&EF*&1A=&%;,%U;:BTQ72`^(&1A=&%;,%U;:ETI('L-"B` ("` ("` 
M("` ("` ("!S=V%P17AE8W5T960 /2`Q.PT*("` ("` ("` ("` ("` ('-T
M871I8R!I9B A:7-!<G)A>2$H='EP96]F*&1A=&%;)"TQ72DI*2`H*BAD871A
M6R0M,5TI*2LK.PT*("` ("` ("` ("` ("` (&9O<F5A8V H87)R87D[(&1A
M=&%;,"XN9&Q=*2!S=V%P*&%R<F%Y6VHM,5TL(&%R<F%Y6VI=*3L-"B` ("` 
M("` ("` ('T-"B` ("` ("` ?0T*("` ("` ("!I9B A<W=A<$5X96-U=&5D
M*2!R971U<FX 9&%T85LP73L-"B` ("!]#0H ("` <F5T=7)N(&1A=&%;,%T[
M#0I]#0H-"B\J*E5N<W1A8FQE('-E;&5C=&EO;B!S;W)T+B` 57-E9"!F;W( 
M<VUA;&P <W5B87)R87ES(&EN('%S;W)T+B`J+PT*#0I46S!=('-E;&5C=&EO
M;E-O<G0H5"XN+BDH5"!D871A*2![("`O+U5S960 9F]R('-M86QL('-U8F%R
M<F%Y<R!I;B!Q<V]R="X-"B` ("!I9BAD871A6S!=+FQE;F=T:"`\(#(I(')E
M='5R;B!D871A6S!=.PT*("` (&9O<F5A8V H:3L ,"XN9&%T85LP72YL96YG
M=& M,2D >PT*("` ("` ("!S:7IE7W0 ;6EN4F]W(#T :3L-"B` ("` ("` 
M9F]R96%C:"AJ.R!I*S$N+F1A=&%;,%TN;&5N9W1H*2![#0H ("` ("` ("` 
M("!I9BAD871A6S!=6VI=(#P 9&%T85LP75MM:6Y2;W==*2![#0H ("` ("` 
M("` ("` ("` ;6EN4F]W(#T :CL-"B` ("` ("` ("` ('T-"B` ("` ("` 
M?0T*("` ("` ("!F;W)E86-H*&%R<F%Y.R!D871A*2!S=V%P*&%R<F%Y6VE=
M+"!A<G)A>5MM:6Y2;W==*3L-"B` ("!]#0H ("` <F5T=7)N(&1A=&%;,%T[
M#0I]#0H-"B\J*E-T86)L92!S96QE8W1I;VX <V]R="X (%5S960 9F]R('-M
M86QL('-U8F%R<F%Y<R!I;B!S=&%B;&51<V]R="!A;F0 ;65R9V53;W)T+ T*
M("H 268 ;&%S="!A<F=U;65N="!I<R!A('5L;VYG*BP :V5E<', =')A8VL 
M;V8 ;G5M8F5R(&]F('-W87!S('1H870 =V]U;&0 :&%V92!B965N#0H *B!N
M96-E<W-A<GD :68 =&AI<R!W97)E(&$ 8G5B8FQE('-O<G0N*B\-" T*5%LP
M72!S=&%B;&5396QE8W1I;VY3;W)T*%0N+BXI*%0 9&%T82D >R` +R]5<V5D
M(&9O<B!S;6%L;"!S=6)A<G)A>7, :6X <W1A8FQE47-O<G0L(&UE<F=E4V]R
M="X-"B` ("!S=&%T:6, :68H(6ES07)R87DA*'1Y<&5O9BAD871A6R0M,5TI
M*2D :6YV87)I86YT('5I;G0 9&P /2!D871A+FQE;F=T:"`M(#$[#0H ("` 
M96QS92!I;G9A<FEA;G0 =6EN="!D;"`](&1A=&$N;&5N9W1H.PT*("` (&EF
M*&1A=&%;,%TN;&5N9W1H(#P ,BD >W)E='5R;B!D871A6S!=.WT-"B` ("!F
M;W)E86-H*&D[(#`N+F1A=&%;,%TN;&5N9W1H+3$I('L-"B` ("` ("` <VEZ
M95]T(&UI;E)O=R`](&D[#0H ("` ("` (&9O<F5A8V H:CL :2LQ+BYD871A
M6S!=+FQE;F=T:"D >PT*("` ("` ("` ("` :68H9&%T85LP75MJ72`\(&1A
M=&%;,%U;;6EN4F]W72D >PT*("` ("` ("` ("` ("` (&UI;E)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VYE+F1U
M<"P ;51W;R`](&)4=V\N9'5P.PT*("` ("` ("!B=6)B;&53;W)T*&)/;F4L
M(&)4=V\I.PT*("` ("` ("!S=&%B;&5396QE8W1I;VY3;W)T*'-/;F4L('-4
M=V\I.PT*("` ("` ("!M97)G95-O<G0H;4]N92P ;51W;RD[#0H ("` ("` 
M('-T86)L95%S;W)T*'%/;F4L('%4=V\I.PT*("` ("` ("!A<W-E<G0H:7-3
M;W)T960H<T]N92DI.PT*("` ("` ("!A<W-E<G0H:7-3;W)T960H8D]N92DI
M.PT*("` ("` ("!A<W-E<G0H:7-3;W)T960H<4]N92DI.PT*("` ("` ("!A
M<W-E<G0H:7-3;W)T960H;4]N92DI.PT*("` ("` ("!A<W-E<G0H<U1W;R`]
M/2!B5'=O*3L-"B` ("` ("` 87-S97)T*&)4=V\ /3T <51W;RD[#0H ("` 
M("` (&%S<V5R="AQ5'=O(#T](&U4=V\I.PT*("` ('T-"B` ("!W<FET969L
<;B B4&%S<V5D('-O<G0 =&5S="XB*3L-"GT-" ``
`
end
begin 644 phobosSort.html
M/&AT;6P^/&AE860^#0H)/$U%5$$ :'1T<"UE<75I=CTB8V]N=&5N="UT>7!E
M(B!C;VYT96YT/2)T97AT+VAT;6P[(&-H87)S970]=71F+3 B/ T*"3QT:71L
M93YP:&]B;W-3;W)T/"]T:71L93X-" D\+VAE860^/&)O9'D^#0H)/& Q/G!H
M;V)O<U-O<G0\+V Q/ T*"3PA+2T 1V5N97)A=&5D(&)Y($1D;V, 9G)O;2!P
M:&]B;W-3;W)T+F0 +2T^#0H\8G(^/&)R/ T*/&1L/CQD=#X\8FEG/E1;72`\
M=3YN97=6;VED/"]U/BA4*2AS:7IE7W0 /&D^;&5N9W1H/"]I/BD[#0H\+V)I
M9SX\+V1T/ T*/&1D/E)E='5R;G, 82!N97< 5%M=+"!S:VEP<&EN9R!I;FET
M:6%L:7IA=&EO;BX (%5S969U;"!W:&5N(&9A<W0 ;65M;W)Y#0H 86QL;V-A
M=&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7, 82!U;&]N9RHL(&ME97!S('1R
M86-K(&]F(&YU;6)E<B!O9B!S=V%P<R!T:&%T('=O=6QD(&AA=F4 8F5E; T*
M(&YE8V5S<V%R>2!I9B!T:&ES('=E<F4 82!B=6)B;&4 <V]R="X-"CQB<CX\
M8G(^#0H-"CPO9&0^#0H\+V1L/ T*#0H)/&AR/CQS;6%L;#Y086=E(&=E;F5R
M871E9"!B>2`\82!H<F5F/2)H='1P.B\O=W=W+F1I9VET86QM87)S+F-O;2]D
M+S(N,"]D9&]C+FAT;6PB/D1D;V,\+V$^+B`\+W-M86QL/ T*"3PO8F]D>3X\
(+VAT;6P^#0H`
`
end
Jul 06 2008
next sibling parent bearophile <bearophileHUGS mailas.com> writes:
I haven't tried your code (yet), but I suggest you to not use too much long
lines (90-100 chars is probably enough).

Your code contains both the forms:
    foreach(ti, array; data) temp[ti][index] = array[$-1];
    ...
    foreach(i, array; temp) {
        data[i][0..$] = array[0..$];
    }

I suggest you to use the second form, or the following one if you want to save
a line:
    foreach (i, array; temp)
        data[i][0..$] = array[0..$];

I suggest you to avoid writing a single large unittest, but to add one block of
unittests under each function/class/method, so you can isolate them better,
disable them, etc (even better is having a standard way to give them a name, so
the program/compiler that executes the unit tests knows what
function/class/method are broken. D unittest system needs just small
improvements to become good enough for small/medium size programs).

Bye,
bearophile
Jul 06 2008
prev sibling parent superdan <super dan.org> writes:
dsimcha Wrote:

 I've been working on implementing some statistics functions in D, and noticed
 that it would be nice if a multisort function were in Phobos.  Such a function
 would take N arrays in and sort them by the first one.  The common way to
 handle something like this seems to be to make a struct with the fields, make
 opCmp point to whatever field you want to sort by, and then use a regular
 sorting algorithm.  This is slow and a pain.  I've implemented a few different
 multisort functions, along with documentation and unit testing, and would like
 to contribute them to Phobos.  I've attached the source file and the Ddoc
 documentation.
yarp i needed this 2. sounds good but it's unnecessary. sort does all that shit easily. int[] arr1; float[] arr2; string[] arr3; // sort three arrays as one void mySwap(int* a, int* b) { auto i = a - arr1.ptr, j = b - arr1.ptr; iterSwap(a, b); swap(arr2[i], arr2[j]); swap(arr3[i], arr3[j]); } sort!("a < b", SwapStrategy.unstable, mySwap)(arr1); what happens is that whenever two doods in arr1 get swapped, the corresponding doods in arr2 and arr3 get swapped too. i don't know why the docs don't give such examples. there's just a hint "Possible uses include notifying observers, counting the number of operations, or manipulating multiple collections in lockstep." the lockstep thing gave it away. & of course you deserve shoe heel beating for putting bubblesort in there. no matter how much you warn against its usage.
Jul 06 2008