added state-space reduce function ( check the sort part)
Merge remote-tracking branch 'origin/master'