title: ORDER BY not behaving as expected
body: <p><strong>Good day.</strong></p>
  
  <p><strong>First i have query:</strong></p>
  
  <pre><code>   ;
      WITH ranked AS (
        SELECT
          p.id_price as p_id_price, 
          p.id_service as p_id_service, 
          p.name as p_name, 
          p.name_original as p_name_original, 
          p.id_producer_country as p_id_producer_country, 
          p.id_firm as p_id_firm, 
          f.name as f_name, 
          f.address as f_address, 
          f.phone as f_phone, 
          city.name as city_name, 
          pc.name as pc_name,
          ROW_NUMBER() OVER (
            PARTITION BY p.id_firm
            ORDER BY
              CASE  -- this criterion puts matching products before non-matching ones
                WHEN p.name like '%test%' COLLATE SQL_Latin1_General_Cp1251_CI_AS
                THEN 1 ELSE 2
              END,
              p.id_price  -- you may use any sorting criteria at this point,
                          -- just ensure it makes the results predictable
          ) AS rnk
        FROM Price p 
        left join Firm f 
          on f.id_service=p.id_service 
          AND f.id_city=p.id_city 
          AND f.id_firm=p.id_firm 
        left join City city 
          on city.id_city = p.id_city 
        left join Producer_country pc 
          on pc.id_producer_country = p.id_producer_country 
        WHERE p.id_city='73041' 
          AND p.include='1' 
          AND p.blocked='0' 
          AND f.blocked='0' 
          AND ( f.name like '%test%' COLLATE SQL_Latin1_General_Cp1251_CI_AS
             OR p.name like '%test%' COLLATE SQL_Latin1_General_Cp1251_CI_AS )
      )
      SELECT *
      FROM ranked
      WHERE rnk = 1 
  ORDER  BY CASE WHEN f_name LIKE '%$..' THEN 0 ELSE 1 END,
                f_name
          ;
  </code></pre>
  
  <p><strong>The ORDER BY did not work:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/17BHZ.png" alt="results"></p>
  
  <p><strong><a href="http://sqlfiddle.com/#!3/c4802/2" rel="nofollow noreferrer">Structure tables here</a></strong></p>
  
  <p><strong>I need to f_name sort in ascending numbers after the $ sign</strong></p>
  
  <p>Why didn't the <code>ORDER BY</code> behave as expected?</p>