mainsort first version complete  
need test