Provided the loops are not nested, your final result is correct, in my opinion. Since
for i = 1 to k do
c[i] = 0
for j = 1 to n do
c[A[j]] = c[A[j]] + 1
for i = 2 to k do
c[i] = c[i] + c[i-1]
for j = n-1 down to 1
B[ c[A[j]]] = A[j]
c[A[j]] = c[A[j]] - 1
That makes complexity go with
(2*n*const)
, that is
O(n)
.