ksort can be moved to first if block as in the last one `$scriptHtmlOptions` is empty array anyway