Variant of Counting sort /Sorting algorithm

there is a problem which gives me a random number as a pivot, and i have to sort my array w.r.t to this pivot (closest come first then farthest)
for e.g.

array =[2,7,4,6,4,4,5,3,6,9,1,1,9] and

pivot=5

expected output: [5,4,4,6,6,3,7,2,1,1,9,9]

is this a variation of counting sort by any chance? if not ! can anyone give me a clue towards solving this problem?
I am encountering a roadblock in thinking on how to handle the counts and the array indices
Therefore, so far i have been able to do this