Fixes #8551 - host recieves correct smart_class_parameter value when multiple overrides in inherited Host Groups exist for parameter

@domcleal thanks for the testing and the comments.
I changed the `sort_by` but there might be a better way then using the `-1`.
I wanted to order by index and then by descending length in one `sort_by`