Inverse function fix, sorting fix