Inventory Sorting

Inventory Sorting

15M Downloads

Sorting by name in Chinese

AstroAbyss opened this issue · 28 comments

commented

I’m not sure if this is an issue, but after some consideration, I can only post it here.

I would like to know the sorting logic/principle of other languages, such as Chinese, when the sorting type is "name"?

commented

Always better to ask then not! Maybe sometimes the "Discussions" are the best but not sure.

The sort should take the translated name into account as it comes from Minecraft

commented

Yes, I am indeed hesitating whether to post it in "Discussions" instead of here.

That is to say, this sorting is based on Minecraft itself?

commented

Yes, because this "name" sorting is practically unusable in Chinese contexts. We are more accustomed to sorting by the initial letters of pinyin.

The information I found is that Minecraft uses "Unicode" for sorting?

commented

Minecraft supplies the translated name of the item and then we use Java's built in string comparator to compare them.
I've tested it in latin-based languages I know but I'm not sure how well it behaves with non-latin characters. I assume you found something?

commented

Minecraft simply gives me the letters involved in the name of an item.
The "sort" itself happens within the programming language's internals but it seems like it's not smart enough for our needs.

Can you give me an unsorted list of strings please and then an expected order?

{
  "unordered": ["this", "that", "and another one"],
  "ordered": ["and another one", "that", "this"]
}

I can then use it for testing and know if I've solved the problem :)

The more comprehensive, the better!

commented

Perhaps the "pinyin4j" and "tiny-pinyin" libraries in Java can help you?

commented

A test-case like I asked above would be way more helpful :)

commented

My fault, that's it.

{
  "unordered": ["下界合金", "苹果", "钻石"],
  "disassembled": ["xia jie he jin", "ping guo", "zuan shi"],
  "ordered": ["ping guo", "xia jie he jin", "zuan shi"]
}
commented

So like this in the end?

{
    "unordered": ["下界合金", "苹果", "钻石"],
    "ordered": ["苹果", "下界合金", "钻石"]
}
commented

Fortunately for me I don't need to understand it, I just need to know what the expected output it for a given input :)
I also need to find ways to handle all other languages that have different rules like Arabic, Japanese, Korean and even French and some others. So the best you can do is give me a very comprehensive input-output list like above.

If I use the correct way to sort things, I should get the same output if I feed in our tests to it.

commented

So like this in the end?

{
    "unordered": ["下界合金", "苹果", "钻石"],
    "ordered": ["苹果", "下界合金", "钻石"]
}

That's right

commented

Because I am concerned that you may not understand the meaning of pinyin. :(

It is important to change Chinese characters to pinyin.

commented

ChatGPT made me this:

{
  "language": "Chinese (Simplified)",
  "locale": "zh_CN",
  "unordered": [
    "白色混凝土",
    "白色羊毛",
    "白色陶瓦",
    "红色地毯",
    "黑色地毯",
    "砖楼梯",
    "砖墙",
    "光滑的石头",
    "透明冰",
    "透明玻璃"
  ],
  "expected_ordered": [
    "白色混凝土",
    "白色陶瓦",
    "白色羊毛",
    "光滑的石头",
    "红色地毯",
    "透明冰",
    "透明玻璃",
    "砖楼梯",
    "砖墙",
    "黑色地毯"
  ]
}

Is this correct by any chance?

commented

There was a small mistake.
The correct sequence should be as follows:

{
  "language": "Chinese (Simplified)",
  "locale": "zh_CN",
  "unordered": [
    "白色混凝土",
    "白色羊毛",
    "白色陶瓦",
    "红色地毯",
    "黑色地毯",
    "砖楼梯",
    "砖墙",
    "光滑的石头",
    "透明冰",
    "透明玻璃"
  ],
  "expected_ordered": [
    "白色混凝土",
    "白色陶瓦",
    "白色羊毛",
    "光滑的石头",
    "黑色地毯",
    "红色地毯",
    "透明冰",
    "透明玻璃",
    "砖楼梯",
    "砖墙"
  ]
}
commented

Amazing, thank you!

I have a potential solution in mind. Will let you know if there's anything to test.

In the meantime if you know anyone who could supply more examples in other languages, don't hold back

commented

You can think of them this way:

{
  "unordered": [
    "白色混凝土",
    "白色羊毛",
    "白色陶瓦",
    "红色地毯",
    "黑色地毯",
    "砖楼梯",
    "砖墙",
    "光滑的石头",
    "透明冰",
    "透明玻璃"
  ],
  "pinyin_initial": [
    "b s h n t",
    "b s y m",
    "b s t w",
    "h s d t",
    "h s d t",
    "z l t",
    "z q",
    "g h d s t",
    "t m b",
    "t m b l"
  ]
}

Here's a small note: "光滑的石头" is not the correct translation, "平滑石头" is the accurate one. :)

commented

Amazing, thank you!

I have a potential solution in mind. Will let you know if there's anything to test.

In the meantime if you know anyone who could supply more examples in other languages, don't hold back

Sure.

commented

No, this is the effect displayed on the English (US) language interface.

There is indeed a display issue with the Chinese translation, as I copied the wrong emoji, so it has been corrected.
It should be pointed out that the display effect of emojis in Minecraft is not satisfactory. :(

commented

And what happened??

Image

commented

Oh lol that's probably a minecraft issue. Minecraft in Chinese doesn't do the emoji well? Might be a bug report for Minecraft

commented

And what happened??

Image

This looks more like the result of encoding/transcoding errors.

commented

Image

This is how it looks like on my screen. Very interesting!

commented

The code shows the 💻 emoji as a text literal and nothing else. Feels like this is some weird edge case with Minecraft's new emoji formatting on Chinese computers. What does it say instead of the emojies?

commented

But I can type this emoji normally during the chat. 💻

Image

commented

No, this is the effect displayed on the English (US) language interface.

There is indeed a display issue with the Chinese translation, as I copied the wrong emoji, so it has been corrected. It should be pointed out that the display effect of emojis in Minecraft is not satisfactory. :(

This means that you used 🧡 in "support", But I used ❤ before.

Image

Image

This is so sad. 😢

commented

Yeah, it's working like this screenshot.

Image

But I think we still need to observe it more closely to see if any other issues might arise.

commented

🎉 This issue has been resolved in version 2.0.3 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀