implmented sorting through and through