Why does my array sort order changes when I pass it to JS using WP_REST_Response?

Fix by using:

return new \WP_REST_Response( \json_encode( $return_data), 200 );