The order is determined by the Church and has actually changed at times over the centuries. I’m not entirely sure about the old testament but I believe that they are grouped by type (Pentateuch, major prophets, minor prophets, etc.).
In the New Testament, The Gospels are placed first in the order that tradition (note the lower-case T indicating that this is not a matter of faith) maintains they were written. This is why Acts is separated from Luke even though Luke leads directly into Acts. Acts is next because it deals with the historical acts of the Church, primarily focusing on Peter in the beginning and Paul in the end. After that are the writings directed to particular Churches. Then come the writings written to all of the Churches and last comes Revelation which is a mystic vision of Heaven, what the Church would experience in the near future, and the end of time all combined together.