I have audio packets with a sequence number at the start, which is 4 bytes.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
dos.writeInt(sequenceNumber);
I receive the packets in a random order, which I then place into a buffer, so an array of arrays.
I was wondering what would be the best way to order the packets by the sequence number.
I retrieve the sequence number like:
ByteArrayInputStream bos = new ByteArrayInputStream(udpPacketBytes);
DataInputStream ds = new DataInputStream(bos);
int receivedValue = ds.readInt();
Is there a way without removing the sequence number that I can order the entire byte array by said sequence number?