ÿþf u n c t i o n   s o r t ( e l , s t r o )   {  
 i f   ( e v e n t . k e y C o d e ! = 1 3   & &   s t r o = = 0   ) { r e t u r n }  
  
 v a r   c o l _ s o r t   =   e l . i n n e r H T M L ; v a r   t r   =   e l . p a r e n t N o d e ; v a r   t a b l e   =   t r . p a r e n t N o d e ; v a r   t d ,   a r r o w ,   c o l _ s o r t _ n u m ;  
 v a r   s t a r t   =   n e w   D a t e ( ) . g e t T i m e ( )  
 v a r   f i l   =   n e w   A r r a y ( )  
 f o r   ( v a r   i = 0 ;   ( t d   =   t r . g e t E l e m e n t s B y T a g N a m e ( " t d " ) . i t e m ( i ) ) ;   i + + )   {  
   f i l [ i ]   = d o c u m e n t . g e t E l e m e n t B y I d ( ' t b _ s t ' + i ) . v a l u e . t o U p p e r C a s e (   ) ;  
       	 i f   ( t d . i n n e r H T M L   = =   c o l _ s o r t )   {  
                         c o l _ s o r t _ n u m   =   i ;  
 i f ( s t r o = = 1 ) {    
               	 i f   ( t d . p r e v s o r t   = =   " y " ) {  
 	         a r r o w   =   t d . f i r s t C h i l d ;  
 	         e l . u p   =   N u m b e r ( ! e l . u p ) ;  
 	 } e l s e {  
 	         t d . p r e v s o r t   =   " y " ;  
 	         a r r o w   =   t d . i n s e r t B e f o r e ( d o c u m e n t . c r e a t e E l e m e n t ( " s p a n " ) , t d . f i r s t C h i l d ) ;  
 	         e l . u p   =   0 ; }  
 	 a r r o w . i n n e r H T M L   =   e l . u p ? ' ‘!  ' : ' “!  ' ;  
 / * w i t h   ( t d . s t y l e ) { c o l o r = " # 0 0 8 0 8 0 " ; b o r d e r C o l o r = " " ; b a c k g r o u n d C o l o r = " " ; } * /  
 { t d . c l a s s N a m e = " s o r t t " }  
 }  
                               } e l s e {  
 i f ( s t r o = = 1 ) {    
                         i f   ( t d . p r e v s o r t   = =   " y " ) {  
                                 t d . p r e v s o r t   =   " n " ;  
                                 i f   ( t d . f i r s t C h i l d )   t d . r e m o v e C h i l d ( t d . f i r s t C h i l d ) ; w i t h   ( t d . s t y l e ) { c o l o r = " " ; b o r d e r C o l o r = " " ; b a c k g r o u n d C o l o r = " " ; }  
 { t d . c l a s s N a m e = " s a p " }  
                           }  
                                     }  
               }  
         }  
           v a r   a   =   n e w   A r r a y ( ) ;  
         f o r ( i = 2 ;   i   <   t a b l e . r o w s . l e n g t h ;   i + + )   {  
 	 a [ i - 2 ]   =   n e w   A r r a y ( ) ;  
                                         a a = t a b l e . r o w s [ i ] . g e t E l e m e n t s B y T a g N a m e ( ' t d ' ) . i t e m ( c o l _ s o r t _ n u m ) . i n n e r H T M L ;  
                                             i f   (   a a . l e n g t h + a a . s u b s t r ( 2 ,   1 ) + a a . s u b s t r ( 5 ,   1 ) = = ' 1 0 . . ' )              
                                               a [ i - 2 ] [ 0 ] = a a . s u b s t r ( 6 ,   4 ) + ' . ' + a a . s u b s t r ( 3 ,   2 ) + ' . ' + a a . s u b s t r ( 0 ,   2 ) ;      
                                           e l s e     i f   ( a a . i n d e x O f ( ' . h t m ' ) = = - 1 )              
                                                 a [ i - 2 ] [ 0 ] = a a ;  
                                           e l s e     {  
                                         h a s = t a b l e . r o w s [ i ] . g e t E l e m e n t s B y T a g N a m e ( ' t d ' ) . i t e m ( c o l _ s o r t _ n u m ) . i n n e r T e x t ;      
                                         h a s = h a s . r e p l a c e ( ' - ' , ' ' ) ;      
                                         h a s = h a s . r e p l a c e ( ' "' , ' ' ) ;    
                                         h a s = h a s . r e p l a c e ( ' "' , ' ' ) ;  
                       / * * / ;   h a s = h a s . r e p l a c e ( n e w   R e g E x p ( S t r i n g . f r o m C h a r C o d e ( 1 0 4 7 ) + S t r i n g . f r o m C h a r C o d e ( 1 0 4 0 ) + S t r i n g . f r o m C h a r C o d e ( 1 0 5 4 ) , ' g ' ) , ' ' ) ;      
                       / * O A O * / ;   h a s = h a s . r e p l a c e ( n e w   R e g E x p ( S t r i n g . f r o m C h a r C o d e ( 1 0 5 4 ) + S t r i n g . f r o m C h a r C o d e ( 1 0 4 0 ) + S t r i n g . f r o m C h a r C o d e ( 1 0 5 4 ) , ' g ' ) , ' ' ) ;      
                                         h a s = h a s . r e p l a c e ( n e w   R e g E x p ( ' " ' , ' g ' ) , ' ' ) ;                                                                                                          
                                         h a s = h a s . r e p l a c e ( n e w   R e g E x p ( '   ' , ' g ' ) , ' ' ) ;                                                                                                                    
                                                                    
                                 a [ i - 2 ] [ 0 ] = h a s . t o U p p e r C a s e (   ) ;                                                                                                                    
                                         }  
 	 a [ i - 2 ] [ 1 ] = t a b l e . r o w s [ i ] ;  
 	 f o r ( f i = 0 ;   f i   <   f i l . l e n g t h ;   f i + + ) {  
 	 a [ i - 2 ] [ 1 + f i + 1 ] = t a b l e . r o w s [ i ] . g e t E l e m e n t s B y T a g N a m e ( ' t d ' ) . i t e m ( f i ) . i n n e r T e x t . t o U p p e r C a s e (   ) }  
 	 	  
 	   }  
 i f ( s t r o = = 1 ) {     a . s o r t ( ) ;   i f ( e l . u p )   a . r e v e r s e ( ) ; }  
 i a a = 0  
 f o r ( i = 0 ;   i   <   a . l e n g t h ;   i + + )   { d i s p = ' ' ;  
 f o r ( f i = 0 ;   f i   <   f i l . l e n g t h ;   f i + + ) {  
 i f   ( f i l [ f i ] = = ' ' ) { c o n t i n u e }  
 i f   ( a [ i ] [ 1 + f i + 1 ] . i n d e x O f ( f i l [ f i ] ) = = - 1 )   { d i s p = ' n o n e ' ; i a a + + ;   b r e a k ; }  
   / / i f   ( a [ i ] [ 1 ] . g e t E l e m e n t s B y T a g N a m e ( " t d " ) . i t e m ( f i ) . i n n e r T e x t . t o U p p e r C a s e (   ) . i n d e x O f ( f i l [ f i ] . t o U p p e r C a s e (   ) ) = = - 1 )   { d i s p = ' n o n e ' ; i a a + + ;   b r e a k ; }  
   }  
   t a b l e . a p p e n d C h i l d ( a [ i ] [ 1 ] ) . s t y l e . d i s p l a y   =   d i s p ;  
     }    
 v a r   s t a r t 1   =   n e w   D a t e ( ) . g e t T i m e ( )  
 / / w i n d o w . s t a t u s = ' { '   +   ( s t a r t 1 - s t a r t ) / 1 0 0 0 + ' } s     (   ' + ( i - i a a ) + '   l i n e s   o f   ' + i + '   ) ' ;  
 d o c u m e n t . t i t l e   = ' { '   +   ( s t a r t 1 - s t a r t ) / 1 0 0 0 + ' } s   (   ' + ( i - i a a ) + '   l i n e s   o f   ' + i + '   )   ' + d o c u m e n t . t i t l e . s u b s t r i n g ( d o c u m e n t . t i t l e . l a s t I n d e x O f ( ' ) ' ) + 1 ) ;  
 / * a l e r t   ( ' O K   ' + ( s t a r t 1 - s t a r t ) ) * / ;  
 }  
 
