J.Rodrigez
J.Rodrigez

Reputation: 11

Sort vector of queue

Someone knew how can I sort queue of queues, which items I've bet in vector of queues?

queue<int> sortedQueue(queue<queue<int>> mainQueue,int countOfChild)
{ 
    queue<int> sorted;
    vector<queue<int>> childQueues;
    for (int i = 0; i < countOfChild; i++)
    {
        queue<int> x = mainQueue.front();
        mainQueue.pop();

        childQueues.push_back(x);
    }
    //TODO
}

Upvotes: 0

Views: 310

Answers (1)

navyblue
navyblue

Reputation: 796

Sorting a vector of queues is as easy as typing std::sort(a_vector_of_queues.begin(), a_vector_of_queues.end()) where a_vector_of_queues is std::vector<std::queue<T>> and T is any type which has < operator defined for it like int or std::string.

Upvotes: 1

Related Questions