Tag values out of order with more than 1 set of data

Hello. I am using InfluxDB 1.8.3. I have a schema as such:
time | y1| y2 | x | index | mac
where y1, y2 and x are fields and index and mac are tags. There are multiple entries for the same mac and timestamp but with different indexes. To ensure that I am able to plot the x values in the correct order on Grafana, the index values are not assigned in ascending order like the x values, i.e.
x | index
0 0
1 1
2 2
3 3
The index values are instead sorted as strings and then assigned which leads to the following ordering,
time | y1| y2 | x | index | mac
111 33 35 0 0 AABBCC001122
111 40 30 1 99 AABBCC001122
111 65 20 2 98 AABBCC001122
111 93 19 3 97 AABBCC001122

I have no issues when I have just one such set in the database. However, when I add another set of data with a different timestamp or mac tag, the two sets do not maintain the index ordering and become jumbled up, causing the x values to also not maintain the ascending order. The ordering is restored when I query to get just 1 set of data of any particular mac but the problem resurfaces when I query for either multiple sets from one mac in a time range or multiple sets from several macs. Any reason why the index tag ordering would mess up?

For a better understanding, the following image show the line graph of x against y1 using plotly.

The first image show the graph of just 1 set of data from 1 mac. The line is smooth because the x values are in order. The second image shows the graph of 2 sets of data with 2 different timestamps from 1 mac. The line is all over the place because the x values are not in order due to the index ordering also changing.

One additional thing I noticed was that when I insert a new set of data on another day, that first set of data is properly ordered. When I insert more sets of data subsequently, not only are these already jumbled up, but the first set of data that was previously ordered now becomes jumbled as well.

Hello @Apurva,
Have you tried grouping by your sets?
It looks like your data is all ungrouped.


Hello! Since we are using InfluxQL on Grafana, I simply created another tag that uses the timestamp and then group by tag(timestamp) when querying. Now all the datasets are returned are in the correct order. Thank you for the nudge in the right direction with that suggestion!