added sorting functionallity with boolean functions to check rectengle and square