```
class Solution(object):
def sortTransformedArray(self, nums, a, b, c):
def f(x): return a*x*x + b*x + c
res = []
low, high = 0, len(nums)-1
while low <= high:
f_low, f_high = f(nums[low]), f(nums[high])
if (a > 0) ^ (f_low > f_high):
res.append(f_high)
high -= 1
else:
res.append(f_low)
low += 1
return res[::-1] if a > 0 else res
```

The solution combine the case where `a==0`

or `b==0`

into the else condition.