Summary: The books of the Bible are organized according to the topic rather than in the order in which they were written. Yes, John wrote the book of Revelation before writing the letters we know as John 1 and 2.
The books of the Hebrew scriptures were organized slightly differently than our King James Old Testament. First is “the law” then “the prophets.” When New Testament writers or Christ spoke of “the law and the prophets” they were referring to the Hebrew scriptures. Next came the books of wisdom or “the writings” including Psalms, Proverbs, Job, etc. The King James Old Testament is also organized according to the topic. Starting with the writings of Moses, followed by historical books, the books of wisdom and ending with the Prophets. The New Testament is similarly organized. First are the Gospels, next are the letters or epistles including those written by John after he wrote Revelation and the last book is the book of prophecy or Revelation of John. A list of the books of the Bible including the author, when and where, as well as the time frame covered, is found on the page answering the question Who Wrote The Bible?.