#include <fstream> #include <iostream> #include <vector> #include <string> #include <algorithm> #include <stdio.h> #include <math.h> #include <windows.h> |
using namespace std; class orders { public: int IOT; // Incoming Order Time int ORD; // ORDer int NOB; // Number Of Bikes int STA; // STAtion int TWO; // Time Window Open int TWC; // Time Window Close int SVT; // SerVice Time bool operator < (const orders& o){ return IOT < o.IOT; } }; |
int main(){ vector<orders> all_orders; // Order vectors chronologically before further processing sort (all_orders.begin(), all_orders.end()); return 0;} |
|
|
I have a vector which contains vectors containing 7 integers each. I'd like to sort these vectors based on the value of the first integer (int IOT), in ascending order. |
orders
class? Or what?But for you the code sorts for example: ((1,2,3,4,5,6,7),(0,1,2,3,4,5,6),(4,5,6,7,8,9,10),(2,3,4,5,6,7,8)) Like ((0,1,2,3,4,5,6),(1,2,3,4,5,6,7),(2,3,4,5,6,7,8)(4,5,6,7,8,9,10)) based on the first integer in each vector? |
|
|
Before sort: { 1 2 3 4 5 6 7 } { 0 1 2 3 4 5 6 } { 4 5 6 7 8 9 10 } { 2 3 4 5 6 7 8 } After sort: { 0 1 2 3 4 5 6 } { 1 2 3 4 5 6 7 } { 2 3 4 5 6 7 8 } { 4 5 6 7 8 9 10 } |
|
|