简体   繁体   English

倒序数字最低变为最高,最高变为最低?

[英]Reverse number order lowest become highest and highest become lowest?

I have a issue, I am using Facebook Score API. 我有一个问题,我正在使用Facebook Score API。 But by default it only sorts scores descending so for example 1000, is higher then 10. But my problem is my scores are based on time, so in my case 10 is better then 1000. And I don't really want to have to do it manually which requires looping over every facebook friend, seeing if they have a score, if they do cache it in an object, then reverse sort it. 但是默认情况下,它仅对降序排序,所以例如1000,则比10高。但是我的问题是我的分数是基于时间的,因此在我的情况下10比1000好。我真的不想做手动操作需要循环遍历每个Facebook朋友,查看他们是否有分数,是否确实将其缓存在对象中,然后反向排序。

So I am wondering if there is some way that I could make 所以我想知道是否有某种方法可以使

10 or 6 or what ever a larger number then 1000 (so basically large numbers become small, and small numbers become large) which could then be reversed. 10或6或大于1000的数字(因此基本上是大数字变小,而小数字变大),然后可以将其取反。 I can do something to both ends (before they are posted, and when I retrieve them). 我可以在两端都做一些事情(在发布它们之前以及检索它们时)。 But they have to remain numbers. 但是他们必须保持数字。

Any ideas if this is possible? 有什么想法可能吗?

It cannot be a decimal or a negative number. 不能为小数或负数。 The numbers will never be higher then 100,000 so it's basically 1-100000 这个数字永远不会高于100,000,所以基本上是1-100000

If 100,000 is the highest number the score can be, then store the score as 100000 - actual_score . 如果100,000是最高分数,则将分数存储为100000 - actual_score Later, you can retrieve the actual score by doing the same operation: 100000 - recorded_score . 稍后,您可以通过执行以下操作来检索实际分数: 100000 - recorded_score

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM