If your IDs in Apache IoTDB are all less than 1000000000, you can adjust your timestamp precision in IoTDB to nanoseconds (from milliseconds), and put your id in the 9 digits later than the original time value (in seconds), so that the timestamps will not be repeated. Therefore, you can sort data by ID and also preserve data from the same device with different timestamps.