Find an algorithm that sorts the nodes of a given graph acc. to distance from source node + value of the node's key an unweighted connected graph $G=(V,E)$ all nodes of the graph contain a "serial number" between 1 to V. (V is an integer).

I am trying to come up with an algorithm that sorts all nodes firstly by distance (number of eadges) from source node 's' , secondly- if two nodes have same distance value sort them by value of thier serial number.

complexity required is $O (V+E)$

I tried to solve this via using bfs and then recieve a "bucket" array of distances - for each distance $1,2...$ all nodes within it are in its "bucket".
the problem is, that in order to sort two nodes with same distance according to
their serial number takes at least $O( nlogn)$ of sorting.
 I tried to come up with a use $v-1$ empty arrays and tried to send each "bucket" nodes acc. to their index in the graph and print it - that takes )$V^2$.

This is NOT homework, I really did try my best.
Your comments are appreciated.
Hint:


Use BFS to calculate the distances.
Calculate the scores (sums of distance to source and serial number).
Use counting sort to sort the scores.
Go over the list again and output the vertices in sorted order.