miraculously managed to implement a dynamic sorting functionality