Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialthanh phan
232 PointsWhy we need add * -1?
Can anyone explain it? I don't understand why we need add * -1.
Update: https://teamtreehouse.com/library/serializing-to-a-file sr guys, my question for this video.
David Tomko
7,744 PointsI actually just learned this at work the other day. Basically the compareTo returns a 1 if the thing being compared is less than what it's compared to. It returns a 0 if they're equal, and a -1 if the thing being compared is more than what it's compared to. So multiplying by -1 will order the results in descending order. Where normally it is in ascending order.
David Tomko
7,744 PointsI actually just learned this at work the other day. Basically the compareTo returns a 1 if the thing being compared is less than what it's compared to. It returns a 0 if they're equal, and a -1 if the thing being compared is more than what it's compared to. So multiplying by -1 will order the results in descending order. Where normally it is in ascending order.
Steven Parker
231,261 PointsDavid Tomko — Did you realize you just added the same comment as you put here last month?
Steven Parker
231,261 PointsSteven Parker
231,261 PointsI'm not sure what you're asking about. If it's something from a video, could you provide a link to the video and an approximate time index? And if it's a quiz or challenge, could you provide a link to that page and show the complete code you're working with?