Case insensitive sorting with Firebase orderByChild

穿精又带淫゛_ 提交于 2019-11-26 09:14:13

问题


I’m using a FirebaseRecyclerAdapter to display a list of strings. My query uses orderByChild. The results sorts with capitalize letters first and looks like this:

Item 1, Item 2, Item 3, aItem, bItem, zItem.

How do I use orderByChild resulting in case insensitive sorting?


回答1:


You don't. Kind of.

If you have data you want to sort by but there also needs to be a user representation of that data, keep two versions

posts
  post_id_0
    display_version: William
    sort_version: william
  post_id_1
    display_version: Henry
    sort_version: henry

Of course you could read in all of the data from Firebase and use .toLower or whatever your platform call is and then sort in code.



来源:https://stackoverflow.com/questions/37643459/case-insensitive-sorting-with-firebase-orderbychild

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!