@@ -703,18 +703,20 @@ IEnumerator CountingSort(int[] Array, int place) {
703
703
//count number of occurrences in freq array
704
704
for ( int i = 0 ; i < n ; i ++ ) {
705
705
yield return new WaitForSeconds ( time ) ;
706
- pillars [ i ] . GetComponent < Pillar > ( ) . Color = tempColor ;
706
+ if ( pillars [ i ] . GetComponent < Pillar > ( ) . Color != nextColor )
707
+ pillars [ i ] . GetComponent < Pillar > ( ) . Color = swapColor ;
707
708
freq [ ( Array [ i ] / place ) % 10 ] ++ ;
708
709
}
709
710
710
711
for ( int i = 0 ; i < Array . Length ; i ++ ) {
711
- pillars [ i ] . GetComponent < Pillar > ( ) . Color = whiteColor ;
712
+ if ( pillars [ i ] . GetComponent < Pillar > ( ) . Color != nextColor )
713
+ pillars [ i ] . GetComponent < Pillar > ( ) . Color = whiteColor ;
712
714
}
713
715
714
716
//Change count[i] so that count[i] now contains actual
715
717
//position of this digit in output[]
716
718
for ( int i = 1 ; i < 10 ; i ++ ) {
717
- yield return new WaitForSeconds ( time ) ;
719
+ // yield return new WaitForSeconds(time);
718
720
freq [ i ] += freq [ i - 1 ] ;
719
721
}
720
722
@@ -723,11 +725,13 @@ IEnumerator CountingSort(int[] Array, int place) {
723
725
yield return new WaitForSeconds ( time ) ;
724
726
output [ freq [ ( Array [ i ] / place ) % 10 ] - 1 ] = Array [ i ] ;
725
727
freq [ ( Array [ i ] / place ) % 10 ] -- ;
726
- pillars [ i ] . GetComponent < Pillar > ( ) . Color = tempColor ;
728
+ if ( pillars [ i ] . GetComponent < Pillar > ( ) . Color != nextColor )
729
+ pillars [ i ] . GetComponent < Pillar > ( ) . Color = tempColor ;
727
730
}
728
731
729
732
for ( int i = 0 ; i < Array . Length ; i ++ ) {
730
- pillars [ i ] . GetComponent < Pillar > ( ) . Color = whiteColor ;
733
+ if ( pillars [ i ] . GetComponent < Pillar > ( ) . Color != nextColor )
734
+ pillars [ i ] . GetComponent < Pillar > ( ) . Color = whiteColor ;
731
735
}
732
736
733
737
//Copy the output array to the input Array, Now the Array will
0 commit comments