WordPress Not Sorting By Custom Field

Please read the documentation. 'rating' is not a valid value for orderby. To sort by a custom field you need to use 'orderby' => 'meta_value' or 'meta_value_num'.

Note that a ‘meta_key=keyname‘ must also be present in the query. Note
also that the sorting will be alphabetical which is fine for strings
(i.e. words), but can be unexpected for numbers (e.g. 1, 3, 34, 4, 56,
6, etc, rather than 1, 3, 4, 6, 34, 56 as you might naturally expect).
Use ‘meta_value_num‘ instead for numeric values. You may also specify
‘meta_type‘ if you want to cast the meta value as a specific type.
Possible values are ‘NUMERIC’, ‘BINARY’, ‘CHAR’, ‘DATE’, ‘DATETIME’,
‘DECIMAL’, ‘SIGNED’, ‘TIME’, ‘UNSIGNED’, same as in ‘$meta_query‘.

So your query would be:

$args = array( 
    'posts_per_page' => -1, 
    'orderby'        => 'meta_value_num',
    'meta_key'       => 'rating',
    'order'          => 'ASC'
);

Note that items without a rating will be missing from this query. To include them please see this previous question and answer on the topic:
Orderby meta_value only returns posts that have existing meta_key