@Alex's answer is great and helped me understand things better, so I'll be borrowing ideas from there.
There are hints in the books that tell us that Dumbledore assumed the diary came first.
"A bit... or more," said Dumbledore. "You heard Voldemort, what he
particularly wanted from Horace was an opinion on what would happen to
the wizard who created more than one Horcrux, what would happen to the
wizard so determined to evade death that he would be prepared to
murder many times, rip his soul repeatedly, so as to store it in many,
separately concealed Horcruxes." Book 6, Chapter 23
Harry repeats this again at a later time.
"He only approached Slughorn to find out what would happen if you
split your soul into seven," said Harry. "Dumbledore was sure Riddle
already knew how to make a Horcrux by the time he asked Slughorn about
them." Book 7, Chapter 6
Tom Riddle had created a horcrux already, just one. Now, why can we rule out the ring? Here are a few more excerpts.
"There was the much younger Slughorn, with his thick, shiny,
straw-colored hair and his gingery-blond mustache, sitting again in
the comfortable winged armchair in his office, his feet resting upon a
velvet pouffe, a small glass of wine in one hand, the other rummaging
in a box of crystallized pineapple. And there were the half dozen
teenage boys sitting around Slughorn with Tom Riddle in the midst of
them, Marvolo's gold-and-black ring gleaming on his finger." Book 6, Chapter 23
Dumbledore, about finding the ring:
"I stumbled across the ring hidden in the ruin of the Gaunt's
house. It seems that once Voldemort had succeeded in sealing a piece
of his soul inside it, he did not want to wear it anymore." Book 6, Chapter 23
So, at least according to Dumbledore, the diary came first.
(Year X refers to Riddle's Xth year at Hogwarts.)
Timeline of events:
- In the summer of 1942, i.e., between Year 4 and Year 5, Riddle steals the ring
- He buys the diary at a store on Vauxhall Road, London, probably during Year 5's Christmas break (end of 1942 to beginning of 1943)
Harry saw at once that it was a diary, and the faded year on the cover
told him it was fifty years old. Book 2, Chapter 13
"I'm telling you, there's nothing to find in there," said Ron. "Riddle
just got a diary for Christmas and couldn't be bothered filling it
in." Book 2, Chapter 13
- Sometime after June 13, 1943 of Year 5 (Myrtle's death) and before Dec 31, 1943 of Year 6 (Riddle's 17th birthday), he turns the diary into a Horcrux
- He talks to Slughorn about Horcruxes at the very end of Year 5 (not very likely because of the Chamber of Secrets issue) or in Year 6
- He turns the ring into a Horcrux (possibly before turning 17 [1], i.e., before 1944)
As for how Dumbledore found out that the diary is Horcrux number 1,
"I guessed. But my guesses have usually been good," said Dumbledore happily. Book 7, Chapter 35
I believe Dumbledore's speculations come the closest to JKR's view of things. Dumbledore explicitly states on multiple occasions that he relied on guesswork. I don't see why the author would repeatedly write about Dumbledore guessing things incorrectly, since it serves no purpose and contributes nothing to the story [2]. If he did guess wrong, I think it would be significant enough to receive a mention later on.
Everything beyond this point can be skipped. What follows comprises lengthy footnotes (which are not references but conjectures) and my opinion on the quote in @Alex's answer.
[1] This is pure guesswork because I'm not sure JKR had Horcruxes in mind when she wrote Book 2 but Riddle may have turned the ring into a Horcrux before turning 17, if we assume the diary Horcrux had two types of enchantment. When Riddle turned the diary into a Horcrux, he may not have enchanted it to possess people; he may have done that after talking to Slughorn. Dumbledore mentions during the Horcrux conversation with Harry that Riddle planned to use the diary as more than a Horcrux, thus being careless about something that makes him immortal.
But don't you see, Harry, that if he intended the diary to be passed
to, or planted on, some future Hogwarts student, he was being
remarkably blase about that precious fragment of his soul concealed
within it. The point of a Horcrux is, as Professor Slughorn explained,
to keep part of the self hidden and safe, not to fling it into
somebody else's path and run the risk that they might destroy it - as
indeed happened: That particular fragment of soul is no more; you saw
to that. Book 6, Chapter 23
If he could afford to be careless about the diary, he must have intended to make more Horcruxes. But he couldn't be sure that was feasible, so he wouldn't put his only Horcrux at risk by messing with it. We know he didn't make his second Horcrux before talking to Slughorn, since he wasn't sure of the repercussions. So, at the very least, Tom didn't rig the diary right after turning it into a Horcrux. But after he turned (or planned to turn) the ring into a Horcrux, he would have been confident about tampering with the book. And we know he was 16 when he enchanted the diary to possess people (unless he was older but had to power to put his younger self's memories into the diary, which I doubt. Pretty sure JKR intended for Riddle's words to be taken at face value).
"I decided to leave behind a diary, preserving my sixteen-year-old
self in its pages, so that one day, with luck, I would be able to lead
another in my footsteps, and finish Salazar Slytherin's noble work."
Book 2, Chapter 19
[2] There have been quite a few instances where Dumbledore had to make guesses (and they almost always turned out right - Riddle's past, Merope's actions, Harry being a Horcrux, and so on). If we questioned his words every time, Voldemort's entire history as we know it could be a lie. Granted, guesswork doesn't equate to fact but in Dumbledore's defense, he didn't come to these conclusions purely based on some fragments of memories he procured. Riddle was his student. He had seven years of exposure to Riddle's insidious nature following which he had more than fifty years to contemplate on things before the Horcrux conversation with Harry. Not to mention, Dumbledore isn't an average wizard. Maybe he noticed subtle changes in Riddle after his first horcrux creation that made more sense in retrospect when Harry handed him the destroyed diary. Maybe he understood Tom well enough to know he was too obsessed about the ring's safety to wear it once he turned it into a horcrux. One can only guess.
I believe Dumbledore's guesses were less about "How did he know that?" and more about JKR using a reliable and knowledgeable character to give us a glimpse of the truth that is otherwise inaccessible to the reader. The story is almost completely from Harry's perspective save for a few chapters. If JKR were to give us these bits of information as facts rather than guesses, she would have had to write from different perspectives. Say, she did write about the horcruxes from Voldemort's perspective. How will that information reach Harry? Voldemort won't be disclosing them for sure (and I doubt anyone can force it out of him without bringing down his reputation as a formidable villain.) What about Merope's side of the story? Even Voldemort would have some trouble piecing things together. So, basically, Dumbledore and his reliable guesses are the way to go. At least, that's the way I see it.
My interpretation of Dumbledore's words (from @Alex's answer):
The careless way in which Voldemort regarded this Horcrux [the diary]
seemed most ominous to me. It suggested that he must have made - or
had been planning to make - more Horcruxes, so that the loss of his
first would not be so detrimental." Book 6, Chapter 23
There is some confusion about the last line. It's ambiguous what Dumbledore meant by "first" because it has multiple interpretations when read on its own. But context is important and I think Dumbledore was referring to the diary in particular, which serves as further proof that the diary came first, so here's my take on things. The point Dumbledore is trying to make is that Voldemort created multiple horcruxes because he had bigger plans for one of them; plans which might jeopardize it. Riddle had bigger plans for his diary. He had conflicted thoughts about the book because on the one hand, it was a Horcrux, meant to be kept safe. On the other, it served as proof of him being the Heir of Slytherin, meant to be read. He didn't have such ambivalent feelings about the ring, as far as we know.
So, the reason "loss" comes up in the conversation is with respect to the diary, since Dumbledore wants to convey that Riddle worried about endangering the soul in the diary and made the ring a Horcrux to strengthen his immortality. If Riddle made the Ring horcrux first, Dumbledore's words make no sense: "Riddle was worried that a single horcrux (the ring) would be problematic since any harm to it would make him mortal again, so he made another horcrux (the diary) with the intention of putting it at a greater risk." One could argue that Riddle didn't immediately plan on using the diary but we'll only be reading too much into things at that point, so I'll skip the counter-arguments. Imo, Dumbledore (and JKR) would have worded things differently, if the ring came first.