Dân IT nói thì ít code thì nhiều phải không ta, coi cái này xem có idea gì không, code dùm thì dạo này tui hơi nhác :">
C++ Code:
void SomeList::sort( bool forward ) { Element* pCurrent_=0; int numErrs = 0; if( forward == true ) { do { numErrs = 0; pCurrent_ = pHead_; while( pCurrent_->pNext_ != 0 ) { if( pCurrent_->value_>pCurrent_->pNext_->value_ ) { std::swap( pCurrent_,pCurrent_->pNext_ ); ++numErrs; } else pCurrent_ = pCurrent_->pNext_; } } while( numErrs != 0 ); } }