There's not really an "ideal" order that is ideal for everyone, the only advice I'd give is that if you have an idea of what you want to do to not do it last or first. You don't want to do it last because you'll need to set your 4th year schedule by then, which is determined by what specialty you plan to do (if you know), and you don't want to do it first because you'll be learning how to be a 3rd year student.
Medicine is nice because if you can do inpatient medicine, you can do pretty much any other rotation for the rest of the year. You also need to know medicine for most shelf exams, so it's helpful in that sense too. The only problem is that the learning curve is pretty steep, if you're not the kind of person who is able to adapt quickly then you could be in for a difficult experience.
Actually I just thought of a suggestion for picking an order. If you're interested in pediatrics, do medicine before you do pediatrics, and vice versa. If you're interested in OB/Gyn, do surgery before OB and vice versa. Your first floor rotation will be mostly about learning how to function as part of a floor team, and in your second rotation you'll be able to really contribute and get more out of the experience. Your first OR rotation will mostly be able learning how to function in an OR, and in your second rotation you'll actually feel like you know why you're doing what you're doing, and will hopefully be pretty good at suturing and knot tying.
Family med and psych can be taken at pretty much any time. Psych is nice to take before a floor rotation just because you learn how to be independent in a low-pressure environment. A rural family med rotation is nice because you get to do a lot. In the "suburban" and "urban" rotations your inpatient time can be mostly scutwork and your outpatient time might involve a lot of shadowing, depending on your preceptor.
Other than that (or even in spite of what I just said), for most people things work out fine. The order isn't quite as important as it seems when you're a second year. There are advantages and disadvantages for any schedule. I scheduled my 3rd year thinking I'd do a specialty I scheduled in the 3rd block (when I'd "know my stuff"), but ended up choosing between the specialties I rotated through in the 1st and last blocks (which contradicts my own advice). I was able to change my fourth year schedule at the last minute to help me make my decision.
So don't worry, however the lottery goes. You can make things work.