java list按照元素對象的指定多個字段屬性進行排序

前些天發現了一個巨牛的人工智能學習網站,通俗易懂,風趣幽默,忍不住分享一下給大家。點擊跳轉到教程。

直接提取重點代碼:

  /*** 把結果集合按時間字段排序,內部類重寫排序規則:* @param list* @return*/private List<WorkWeightDto> sortList(List<WorkWeightDto> list){Collections.sort(list, new Comparator<WorkWeightDto>() {@Overridepublic int compare(WorkWeightDto ww1, WorkWeightDto ww2) {return ww2.getStartTime().compareTo(ww1.getStartTime());}});return list;}

?

-------------------------------------------------------------------------------------------------

以下是詳情:

ListUtils.Java---功能類

?

[java]?view plain?copy
  1. package?com.enable.common.utils;??
  2. ??
  3. import?java.lang.reflect.Field;??
  4. import?java.text.NumberFormat;??
  5. import?java.util.Collections;??
  6. import?java.util.Comparator;??
  7. import?java.util.Date;??
  8. import?java.util.List;??
  9. ??
  10. /**?
  11. ?*?@author?yinaibang?
  12. ?*?在數據庫中查出來的列表中,往往需要對不同的字段重新排序。?一般的做法都是使用排序的字段,重新到數據庫中查詢。?
  13. ?*?如果不到數據庫查詢,直接在第一次查出來的list中排序,無疑會提高系統的性能。?下面就寫一個通用的方法,對list排序,?
  14. ?*??
  15. ?*?至少需要滿足以下5點:?
  16. ?*??
  17. ?*?①.list元素對象類型任意??
  18. ?*??????---->使用泛型解決?
  19. ?*??
  20. ?*?②.可以按照list元素對象的任意多個屬性進行排序,即可以同時指定多個屬性進行排序??
  21. ?*??????--->使用java的可變參數解決?
  22. ?*??
  23. ?*?③.list元素對象屬性的類型可以是數字(byte、short、int、long、float、double等,包括正數、負數、0)、字符串(char、String)、日期(java.util.Date)?
  24. ?*??????--->對于數字:統一轉換為固定長度的字符串解決,比如數字3和123,轉換為"003"和"123"?;再比如"-15"和"7"轉換為"-015"和"007"??
  25. ?*??????--->對于日期:可以先把日期轉化為long類型的數字,數字的解決方法如上?
  26. ?*??
  27. ?*?④.list元素對象的屬性可以沒有相應的getter和setter方法??
  28. ?*??????--->可以使用java反射進行獲取private和protected修飾的屬性值?
  29. ?*??
  30. ?*?⑤.list元素對象的對象的每個屬性都可以指定是升序還是降序?
  31. ?*??????-->使用2個重寫的方法(一個方法滿足所有屬性都按照升序(降序),另外一個方法滿足每個屬性都能指定是升序(降序))?
  32. ?*??
  33. ?*?
  34. ?*/??
  35. public?class?ListUtils?{??
  36. ????/**?
  37. ?????*?對list的元素按照多個屬性名稱排序,?
  38. ?????*?list元素的屬性可以是數字(byte、short、int、long、float、double等,支持正數、負數、0)、char、String、java.util.Date?
  39. ?????*??
  40. ?????*??
  41. ?????*?@param?lsit?
  42. ?????*?@param?sortname?
  43. ?????*????????????list元素的屬性名稱?
  44. ?????*?@param?isAsc?
  45. ?????*????????????true升序,false降序?
  46. ?????*/??
  47. ????public?static?<E>?void?sort(List<E>?list,?final?boolean?isAsc,?final?String...?sortnameArr)?{??
  48. ????????Collections.sort(list,?new?Comparator<E>()?{??
  49. ??
  50. ????????????public?int?compare(E?a,?E?b)?{??
  51. ????????????????int?ret?=?0;??
  52. ????????????????try?{??
  53. ????????????????????for?(int?i?=?0;?i?<?sortnameArr.length;?i++)?{??
  54. ????????????????????????ret?=?ListUtils.compareObject(sortnameArr[i],?isAsc,?a,?b);??
  55. ????????????????????????if?(0?!=?ret)?{??
  56. ????????????????????????????break;??
  57. ????????????????????????}??
  58. ????????????????????}??
  59. ????????????????}?catch?(Exception?e)?{??
  60. ????????????????????e.printStackTrace();??
  61. ????????????????}??
  62. ????????????????return?ret;??
  63. ????????????}??
  64. ????????});??
  65. ????}??
  66. ??????
  67. ????/**?
  68. ?????*?給list的每個屬性都指定是升序還是降序?
  69. ?????*??
  70. ?????*?@param?list?
  71. ?????*?@param?sortnameArr??參數數組?
  72. ?????*?@param?typeArr??????每個屬性對應的升降序數組,?true升序,false降序?
  73. ?????*/??
  74. ??
  75. ????public?static?<E>?void?sort(List<E>?list,?final?String[]?sortnameArr,?final?boolean[]?typeArr)?{??
  76. ????????if?(sortnameArr.length?!=?typeArr.length)?{??
  77. ????????????throw?new?RuntimeException("屬性數組元素個數和升降序數組元素個數不相等");??
  78. ????????}??
  79. ????????Collections.sort(list,?new?Comparator<E>()?{??
  80. ????????????public?int?compare(E?a,?E?b)?{??
  81. ????????????????int?ret?=?0;??
  82. ????????????????try?{??
  83. ????????????????????for?(int?i?=?0;?i?<?sortnameArr.length;?i++)?{??
  84. ????????????????????????ret?=?ListUtils.compareObject(sortnameArr[i],?typeArr[i],?a,?b);??
  85. ????????????????????????if?(0?!=?ret)?{??
  86. ????????????????????????????break;??
  87. ????????????????????????}??
  88. ????????????????????}??
  89. ????????????????}?catch?(Exception?e)?{??
  90. ????????????????????e.printStackTrace();??
  91. ????????????????}??
  92. ????????????????return?ret;??
  93. ????????????}??
  94. ????????});??
  95. ????}??
  96. ??
  97. ????/**?
  98. ?????*?對2個對象按照指定屬性名稱進行排序?
  99. ?????*??
  100. ?????*?@param?sortname?
  101. ?????*????????????屬性名稱?
  102. ?????*?@param?isAsc?
  103. ?????*????????????true升序,false降序?
  104. ?????*?@param?a?
  105. ?????*?@param?b?
  106. ?????*?@return?
  107. ?????*?@throws?Exception?
  108. ?????*/??
  109. ????private?static?<E>?int?compareObject(final?String?sortname,?final?boolean?isAsc,?E?a,?E?b)?throws?Exception?{??
  110. ????????int?ret;??
  111. ????????Object?value1?=?ListUtils.forceGetFieldValue(a,?sortname);??
  112. ????????Object?value2?=?ListUtils.forceGetFieldValue(b,?sortname);??
  113. ????????String?str1?=?value1.toString();??
  114. ????????String?str2?=?value2.toString();??
  115. ????????if?(value1?instanceof?Number?&&?value2?instanceof?Number)?{??
  116. ????????????int?maxlen?=?Math.max(str1.length(),?str2.length());??
  117. ????????????str1?=?ListUtils.addZero2Str((Number)?value1,?maxlen);??
  118. ????????????str2?=?ListUtils.addZero2Str((Number)?value2,?maxlen);??
  119. ????????}?else?if?(value1?instanceof?Date?&&?value2?instanceof?Date)?{??
  120. ????????????long?time1?=?((Date)?value1).getTime();??
  121. ????????????long?time2?=?((Date)?value2).getTime();??
  122. ????????????int?maxlen?=?Long.toString(Math.max(time1,?time2)).length();??
  123. ????????????str1?=?ListUtils.addZero2Str(time1,?maxlen);??
  124. ????????????str2?=?ListUtils.addZero2Str(time2,?maxlen);??
  125. ????????}??
  126. ????????if?(isAsc)?{??
  127. ????????????ret?=?str1.compareTo(str2);??
  128. ????????}?else?{??
  129. ????????????ret?=?str2.compareTo(str1);??
  130. ????????}??
  131. ????????return?ret;??
  132. ????}??
  133. ??
  134. ????/**?
  135. ?????*?給數字對象按照指定長度在左側補0.?
  136. ?????*??
  137. ?????*?使用案例:?addZero2Str(11,4)?返回?"0011",?addZero2Str(-18,6)返回?"-000018"?
  138. ?????*??
  139. ?????*?@param?numObj?
  140. ?????*????????????數字對象?
  141. ?????*?@param?length?
  142. ?????*????????????指定的長度?
  143. ?????*?@return?
  144. ?????*/??
  145. ????public?static?String?addZero2Str(Number?numObj,?int?length)?{??
  146. ????????NumberFormat?nf?=?NumberFormat.getInstance();??
  147. ????????//?設置是否使用分組??
  148. ????????nf.setGroupingUsed(false);??
  149. ????????//?設置最大整數位數??
  150. ????????nf.setMaximumIntegerDigits(length);??
  151. ????????//?設置最小整數位數??
  152. ????????nf.setMinimumIntegerDigits(length);??
  153. ????????return?nf.format(numObj);??
  154. ????}??
  155. ??
  156. ????/**?
  157. ?????*?獲取指定對象的指定屬性值(去除private,protected的限制)?
  158. ?????*??
  159. ?????*?@param?obj?
  160. ?????*????????????屬性名稱所在的對象?
  161. ?????*?@param?fieldName?
  162. ?????*????????????屬性名稱?
  163. ?????*?@return?
  164. ?????*?@throws?Exception?
  165. ?????*/??
  166. ????public?static?Object?forceGetFieldValue(Object?obj,?String?fieldName)?throws?Exception?{??
  167. ????????Field?field?=?obj.getClass().getDeclaredField(fieldName);??
  168. ????????Object?object?=?null;??
  169. ????????boolean?accessible?=?field.isAccessible();??
  170. ????????if?(!accessible)?{??
  171. ????????????//?如果是private,protected修飾的屬性,需要修改為可以訪問的??
  172. ????????????field.setAccessible(true);??
  173. ????????????object?=?field.get(obj);??
  174. ????????????//?還原private,protected屬性的訪問性質??
  175. ????????????field.setAccessible(accessible);??
  176. ????????????return?object;??
  177. ????????}??
  178. ????????object?=?field.get(obj);??
  179. ????????return?object;??
  180. ????}??
  181. }??

?

?

?

UserInfo.java

?

[java]?view plain?copy
  1. package?com;??
  2. ??
  3. import?java.text.SimpleDateFormat;??
  4. import?java.util.Date;??
  5. /**?
  6. ?*??
  7. ?*?@author?yinaibang?
  8. ?*?
  9. ?*/??
  10. public?class?UserInfo?implements?java.io.Serializable?{??
  11. ??
  12. ????private?static?final?long?serialVersionUID?=?-3522051445403971732L;??
  13. ??
  14. ????private?Integer?userId;??
  15. ????private?String?username;??
  16. ????private?Date?birthDate;??
  17. ????private?Integer?age;??
  18. ????private?float?fRate;??
  19. ????private?char?ch;??
  20. ??
  21. ????public?Date?getBirthDate()?{??
  22. ????????return?birthDate;??
  23. ????}??
  24. ??
  25. ????public?String?getBirthDatestr()?{??
  26. ????????SimpleDateFormat?formater?=?new?SimpleDateFormat("yyyy-MM-dd");??
  27. ????????return?formater.format(getBirthDate());??
  28. ????}??
  29. ??
  30. ????public?UserInfo(Integer?userId,?String?username,?Date?birthDate,?Integer?age,?float?fRate,?char?ch)?{??
  31. ????????super();??
  32. ????????this.userId?=?userId;??
  33. ????????this.username?=?username;??
  34. ????????this.birthDate?=?birthDate;??
  35. ????????this.age?=?age;??
  36. ????????this.fRate?=?fRate;??
  37. ????????this.ch?=?ch;??
  38. ????}??
  39. ??
  40. ????@Override??
  41. ????public?String?toString()?{??
  42. ????????return?"UserInfo?[userId="?+?userId?+?",?\tusername="?+?username?+?",?\tbirthDate="?+?getBirthDatestr()??
  43. ????????????????+?",?\tage="?+?age?+?",?fRate="?+?fRate?+?",?ch="?+?ch?+?"]";??
  44. ????}??
  45. ??
  46. }??

?

?

?

?

?

?

Test.java---測試類

?

[java]?view plain?copy
  1. package?com;??
  2. ??
  3. import?java.text.SimpleDateFormat;??
  4. import?java.util.ArrayList;??
  5. import?java.util.List;??
  6. ??
  7. import?com.enable.common.utils.ListUtils;??
  8. ??
  9. /**?
  10. ?*??
  11. ?*?@author?yinaibang?
  12. ?*?
  13. ?*/??
  14. public?class?Test?{??
  15. ??
  16. ????public?static?void?main(String[]?args)?throws?Exception?{??
  17. ??
  18. ????????Test?testObj?=?new?Test();??
  19. ??
  20. ????????List<UserInfo>?list?=?new?ArrayList<UserInfo>();??
  21. ????????//?public?UserInfo(Integer?userId,?String?username,?Date?birthDate,Integer?age,?float?fRate,?char?ch)??
  22. ????????SimpleDateFormat?formater?=?new?SimpleDateFormat("yyyy-MM-dd");??
  23. ????????UserInfo?user1?=?new?UserInfo(3,?"bbb",?formater.parse("1980-12-01"),?1,?1.2f,?'a');??
  24. ????????UserInfo?user2?=?new?UserInfo(0,?"126",?formater.parse("1900-10-11"),?03,?-3.6f,?'c');??
  25. ????????UserInfo?user3?=?new?UserInfo(12,?"5",?formater.parse("1973-08-21"),?15,?9.32f,?'f');??
  26. ????????UserInfo?user4?=?new?UserInfo(465,?"1567",?formater.parse("2012-01-26"),?20,?12.56f,?'0');??
  27. ????????UserInfo?user5?=?new?UserInfo(2006,?"&4m",?formater.parse("2010-05-08"),?100,?165.32f,?'5');??
  28. ????????UserInfo?user6?=?new?UserInfo(5487,?"hf67",?formater.parse("2016-12-30"),?103,?56.32f,?'m');??
  29. ????????UserInfo?user7?=?new?UserInfo(5487,"jigg",?formater.parse("2000-10-16"),?103,?56.32f,?'m');??
  30. ????????UserInfo?user8?=?new?UserInfo(5487,?"jigg",?formater.parse("1987-07-25"),?103,?56.32f,?'m');??
  31. ??
  32. ????????list.add(user1);??
  33. ????????list.add(user2);??
  34. ????????list.add(user3);??
  35. ????????list.add(user4);??
  36. ????????list.add(user5);??
  37. ????????list.add(user6);??
  38. ????????list.add(user7);??
  39. ????????list.add(user8);??
  40. ??
  41. ????????System.out.println("\n-------原來序列-------------------");??
  42. ????????testObj.printfUserInfoList(list);??
  43. ??
  44. ????????//?按userId升序、username降序、birthDate升序排序??
  45. ????????String?[]?sortNameArr?=?{"userId","username","birthDate"};??
  46. ????????boolean?[]?isAscArr?=?{true,false,true};??
  47. ????????ListUtils.sort(list,sortNameArr,isAscArr);??
  48. ????????System.out.println("\n--------按按userId升序、username降序、birthDate升序排序(如果userId相同,則按照username降序,如果username相同,則按照birthDate升序)------------------");??
  49. ????????testObj.printfUserInfoList(list);??
  50. ??????????
  51. ????????//?按userId、username、birthDate都升序排序??
  52. ????????ListUtils.sort(list,?true,?"userId",?"username","birthDate");??
  53. ????????System.out.println("\n--------按userId、username、birthDate排序(如果userId相同,則按照username升序,如果username相同,則按照birthDate升序)------------------");??
  54. ????????testObj.printfUserInfoList(list);??
  55. ??
  56. ????????//?按userId、username都倒序排序??
  57. ????????ListUtils.sort(list,?false,?"userId",?"username");??
  58. ????????System.out.println("\n--------按userId和username倒序(如果userId相同,則按照username倒序)------------------");??
  59. ????????testObj.printfUserInfoList(list);??
  60. ??
  61. ????????//?按username、birthDate都升序排序??
  62. ????????ListUtils.sort(list,?true,?"username",?"birthDate");??
  63. ????????System.out.println("\n---------按username、birthDate升序(如果username相同,則按照birthDate升序)-----------------");??
  64. ????????testObj.printfUserInfoList(list);??
  65. ??
  66. ????????//?按birthDate倒序排序??
  67. ????????ListUtils.sort(list,?false,?"birthDate");??
  68. ????????System.out.println("\n---------按birthDate倒序-----------------");??
  69. ????????testObj.printfUserInfoList(list);??
  70. ??
  71. ????????//?按fRate升序排序??
  72. ????????ListUtils.sort(list,?true,?"fRate");??
  73. ????????System.out.println("\n---------按fRate升序-----------------");??
  74. ????????testObj.printfUserInfoList(list);??
  75. ??
  76. ????????//?按ch倒序排序??
  77. ????????ListUtils.sort(list,?false,?"ch");??
  78. ????????System.out.println("\n---------按ch倒序-----------------");??
  79. ????????testObj.printfUserInfoList(list);??
  80. ??
  81. ????}??
  82. ??
  83. ????private?void?printfUserInfoList(List<UserInfo>?list)?{??
  84. ????????for?(UserInfo?user?:?list)?{??
  85. ????????????System.out.println(user.toString());??
  86. ????????}??
  87. ????}??
  88. }??

?

?

?

運行結果

?

[java]?view plain?copy
  1. -------原來序列-------------------??
  2. UserInfo?[userId=3,?????username=bbb,???birthDate=1980-12-01,???age=1,?fRate=1.2,?ch=a]??
  3. UserInfo?[userId=0,?????username=126,???birthDate=1900-10-11,???age=3,?fRate=-3.6,?ch=c]??
  4. UserInfo?[userId=12,????username=5,?????birthDate=1973-08-21,???age=15,?fRate=9.32,?ch=f]??
  5. UserInfo?[userId=465,???username=1567,??birthDate=2012-01-26,???age=20,?fRate=12.56,?ch=0]??
  6. UserInfo?[userId=2006,??username=&4m,???birthDate=2010-05-08,???age=100,?fRate=165.32,?ch=5]??
  7. UserInfo?[userId=5487,??username=hf67,??birthDate=2016-12-30,???age=103,?fRate=56.32,?ch=m]??
  8. UserInfo?[userId=5487,??username=jigg,??birthDate=2000-10-16,???age=103,?fRate=56.32,?ch=m]??
  9. UserInfo?[userId=5487,??username=jigg,??birthDate=1987-07-25,???age=103,?fRate=56.32,?ch=m]??
  10. ??
  11. --------按按userId升序、username降序、birthDate升序排序(如果userId相同,則按照username降序,如果username相同,則按照birthDate升序)------------------??
  12. UserInfo?[userId=0,?????username=126,???birthDate=1900-10-11,???age=3,?fRate=-3.6,?ch=c]??
  13. UserInfo?[userId=3,?????username=bbb,???birthDate=1980-12-01,???age=1,?fRate=1.2,?ch=a]??
  14. UserInfo?[userId=12,????username=5,?????birthDate=1973-08-21,???age=15,?fRate=9.32,?ch=f]??
  15. UserInfo?[userId=465,???username=1567,??birthDate=2012-01-26,???age=20,?fRate=12.56,?ch=0]??
  16. UserInfo?[userId=2006,??username=&4m,???birthDate=2010-05-08,???age=100,?fRate=165.32,?ch=5]??
  17. UserInfo?[userId=5487,??username=jigg,??birthDate=1987-07-25,???age=103,?fRate=56.32,?ch=m]??
  18. UserInfo?[userId=5487,??username=jigg,??birthDate=2000-10-16,???age=103,?fRate=56.32,?ch=m]??
  19. UserInfo?[userId=5487,??username=hf67,??birthDate=2016-12-30,???age=103,?fRate=56.32,?ch=m]??
  20. ??
  21. --------按userId、username、birthDate排序(如果userId相同,則按照username升序,如果username相同,則按照birthDate升序)------------------??
  22. UserInfo?[userId=0,?????username=126,???birthDate=1900-10-11,???age=3,?fRate=-3.6,?ch=c]??
  23. UserInfo?[userId=3,?????username=bbb,???birthDate=1980-12-01,???age=1,?fRate=1.2,?ch=a]??
  24. UserInfo?[userId=12,????username=5,?????birthDate=1973-08-21,???age=15,?fRate=9.32,?ch=f]??
  25. UserInfo?[userId=465,???username=1567,??birthDate=2012-01-26,???age=20,?fRate=12.56,?ch=0]??
  26. UserInfo?[userId=2006,??username=&4m,???birthDate=2010-05-08,???age=100,?fRate=165.32,?ch=5]??
  27. UserInfo?[userId=5487,??username=hf67,??birthDate=2016-12-30,???age=103,?fRate=56.32,?ch=m]??
  28. UserInfo?[userId=5487,??username=jigg,??birthDate=1987-07-25,???age=103,?fRate=56.32,?ch=m]??
  29. UserInfo?[userId=5487,??username=jigg,??birthDate=2000-10-16,???age=103,?fRate=56.32,?ch=m]??
  30. ??
  31. --------按userId和username倒序(如果userId相同,則按照username倒序)------------------??
  32. UserInfo?[userId=5487,??username=jigg,??birthDate=1987-07-25,???age=103,?fRate=56.32,?ch=m]??
  33. UserInfo?[userId=5487,??username=jigg,??birthDate=2000-10-16,???age=103,?fRate=56.32,?ch=m]??
  34. UserInfo?[userId=5487,??username=hf67,??birthDate=2016-12-30,???age=103,?fRate=56.32,?ch=m]??
  35. UserInfo?[userId=2006,??username=&4m,???birthDate=2010-05-08,???age=100,?fRate=165.32,?ch=5]??
  36. UserInfo?[userId=465,???username=1567,??birthDate=2012-01-26,???age=20,?fRate=12.56,?ch=0]??
  37. UserInfo?[userId=12,????username=5,?????birthDate=1973-08-21,???age=15,?fRate=9.32,?ch=f]??
  38. UserInfo?[userId=3,?????username=bbb,???birthDate=1980-12-01,???age=1,?fRate=1.2,?ch=a]??
  39. UserInfo?[userId=0,?????username=126,???birthDate=1900-10-11,???age=3,?fRate=-3.6,?ch=c]??
  40. ??
  41. ---------按username、birthDate升序(如果username相同,則按照birthDate升序)-----------------??
  42. UserInfo?[userId=2006,??username=&4m,???birthDate=2010-05-08,???age=100,?fRate=165.32,?ch=5]??
  43. UserInfo?[userId=0,?????username=126,???birthDate=1900-10-11,???age=3,?fRate=-3.6,?ch=c]??
  44. UserInfo?[userId=465,???username=1567,??birthDate=2012-01-26,???age=20,?fRate=12.56,?ch=0]??
  45. UserInfo?[userId=12,????username=5,?????birthDate=1973-08-21,???age=15,?fRate=9.32,?ch=f]??
  46. UserInfo?[userId=3,?????username=bbb,???birthDate=1980-12-01,???age=1,?fRate=1.2,?ch=a]??
  47. UserInfo?[userId=5487,??username=hf67,??birthDate=2016-12-30,???age=103,?fRate=56.32,?ch=m]??
  48. UserInfo?[userId=5487,??username=jigg,??birthDate=1987-07-25,???age=103,?fRate=56.32,?ch=m]??
  49. UserInfo?[userId=5487,??username=jigg,??birthDate=2000-10-16,???age=103,?fRate=56.32,?ch=m]??
  50. ??
  51. ---------按birthDate倒序-----------------??
  52. UserInfo?[userId=5487,??username=hf67,??birthDate=2016-12-30,???age=103,?fRate=56.32,?ch=m]??
  53. UserInfo?[userId=465,???username=1567,??birthDate=2012-01-26,???age=20,?fRate=12.56,?ch=0]??
  54. UserInfo?[userId=2006,??username=&4m,???birthDate=2010-05-08,???age=100,?fRate=165.32,?ch=5]??
  55. UserInfo?[userId=5487,??username=jigg,??birthDate=2000-10-16,???age=103,?fRate=56.32,?ch=m]??
  56. UserInfo?[userId=5487,??username=jigg,??birthDate=1987-07-25,???age=103,?fRate=56.32,?ch=m]??
  57. UserInfo?[userId=3,?????username=bbb,???birthDate=1980-12-01,???age=1,?fRate=1.2,?ch=a]??
  58. UserInfo?[userId=12,????username=5,?????birthDate=1973-08-21,???age=15,?fRate=9.32,?ch=f]??
  59. UserInfo?[userId=0,?????username=126,???birthDate=1900-10-11,???age=3,?fRate=-3.6,?ch=c]??
  60. ??
  61. ---------按fRate升序-----------------??
  62. UserInfo?[userId=0,?????username=126,???birthDate=1900-10-11,???age=3,?fRate=-3.6,?ch=c]??
  63. UserInfo?[userId=3,?????username=bbb,???birthDate=1980-12-01,???age=1,?fRate=1.2,?ch=a]??
  64. UserInfo?[userId=12,????username=5,?????birthDate=1973-08-21,???age=15,?fRate=9.32,?ch=f]??
  65. UserInfo?[userId=465,???username=1567,??birthDate=2012-01-26,???age=20,?fRate=12.56,?ch=0]??
  66. UserInfo?[userId=5487,??username=hf67,??birthDate=2016-12-30,???age=103,?fRate=56.32,?ch=m]??
  67. UserInfo?[userId=5487,??username=jigg,??birthDate=2000-10-16,???age=103,?fRate=56.32,?ch=m]??
  68. UserInfo?[userId=5487,??username=jigg,??birthDate=1987-07-25,???age=103,?fRate=56.32,?ch=m]??
  69. UserInfo?[userId=2006,??username=&4m,???birthDate=2010-05-08,???age=100,?fRate=165.32,?ch=5]??
  70. ??
  71. ---------按ch倒序-----------------??
  72. UserInfo?[userId=5487,??username=hf67,??birthDate=2016-12-30,???age=103,?fRate=56.32,?ch=m]??
  73. UserInfo?[userId=5487,??username=jigg,??birthDate=2000-10-16,???age=103,?fRate=56.32,?ch=m]??
  74. UserInfo?[userId=5487,??username=jigg,??birthDate=1987-07-25,???age=103,?fRate=56.32,?ch=m]??
  75. UserInfo?[userId=12,????username=5,?????birthDate=1973-08-21,???age=15,?fRate=9.32,?ch=f]??
  76. UserInfo?[userId=0,?????username=126,???birthDate=1900-10-11,???age=3,?fRate=-3.6,?ch=c]??
  77. UserInfo?[userId=3,?????username=bbb,???birthDate=1980-12-01,???age=1,?fRate=1.2,?ch=a]??
  78. UserInfo?[userId=2006,??username=&4m,???birthDate=2010-05-08,???age=100,?fRate=165.32,?ch=5]??
  79. UserInfo?[userId=465,???username=1567,??birthDate=2012-01-26,???age=20,?fRate=12.56,?ch=0] ?

?

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/451981.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/451981.shtml
英文地址,請注明出處:http://en.pswp.cn/news/451981.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

網絡爬蟲--18.python中的GIL(全局解釋器鎖)、多線程、多進程、并發、并行

參考文獻&#xff1a; python的GIL、多線程、多進程 并發和并行的區別&#xff1f; GIL(全局解釋器鎖)一看就懂的解釋&#xff01; 多謝作者分享&#xff01;

Socket和ServerSocket

對于即時類應用或者即時類的游戲&#xff0c;HTTP協議很多時候無法滿足于我們的需求。這會&#xff0c;Socket對于我們來說就非常實用了。下面是本次學習的筆記。主要分異常類型、交互原理、Socket、ServerSocket、多線程這幾個方面闡述。異常類型在了解Socket的內容之前&#…

徹底搞清楚Android中的 Attr

版權聲明&#xff1a;本文為sydMobile原創文章&#xff0c;轉載請務必注明出處&#xff01; https://blog.csdn.net/sydMobile/article/details/79978187 相信這個詞對于Android開發者來說十分熟悉了&#xff0c;那么你對他到底有多了解呢&#xff1f; 回憶起我剛開始接觸Andr…

D. Relatively Prime Graph

Lets call an undirected graph G(V,E)G(V,E) relatively prime if and only if for each edge (v,u)∈E(v,u)∈E GCD(v,u)1GCD(v,u)1 (the greatest common divisor of vv and uu is 11). If there is no edge between some pair of vertices vv and uu then the value of GC…

解決 : org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

前些天發現了一個巨牛的人工智能學習網站&#xff0c;通俗易懂&#xff0c;風趣幽默&#xff0c;忍不住分享一下給大家。點擊跳轉到教程。 報錯&#xff1a; org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.tanj.mapper.SendDeta…

網絡爬蟲--19.【Scrapy-Redis實戰】分布式爬蟲爬取房天下--環境準備

文章目錄0. 思路一. 虛擬機Ubuntu0中安裝Redis二. 虛擬機Ubuntu1中安裝Redis三. Windows服務器上安裝Redis四. 安裝cmder五. 安裝RedisDesktopManager六. 修改Windows中的配置文件redis.windows.conf七. Ubuntu連接Windows上 的Redis服務器-----------------------------------…

開發人員,請愛護你的身體

最近一周身體極度不適&#xff0c;口腔潰瘍、嗓子痛、感冒咳嗽、發燒&#xff0c;統統來了一個遍&#xff0c;非常痛苦。所以最近一直關注有關于軟件開發人員的身體健康問題的網站、文章。 看了許多文章&#xff0c;在結合自己在這一周之內痛苦的感受&#xff0c;所以才寫這樣…

tkinter中scale拖拉改變值控件(十一)

scale拖拉改變值控件 使用戶通過拖拽改變值 簡單的實現&#xff1a; 1 import tkinter2 3 wuya tkinter.Tk() 4 wuya.title("wuya") 5 wuya.geometry("300x2001020") 6 7 8 # 創建對象 9 scale1 tkinter.Scale(wuya, from_0, to100) 10 scale1.pac…

vue+elementUI開發實踐問題總結

最近公司項目采用vue&#xff0c;實行前后端分離開發&#xff0c;采用element-ui框架&#xff0c;對于項目中遇到的問題進行記錄&#xff0c;便于日后查詢。 vueelementui怎樣點擊table中的單元格觸發事件&#xff1f;官方文檔是采用的cell-click方式。實際項目中需要在不同的t…

Socket的getInputStream()方法

Socket的getInputStream()方法可以獲得網絡連接輸入&#xff0c;同時返回一個InputStream實例 。

計算機圖形學理論(4):緩沖區

本系列根據國外一個圖形小哥的講解為本&#xff0c;整合互聯網的一些資料&#xff0c;結合自己的一些理解。 什么是緩沖區&#xff1f; 緩沖區是保存某些數據的臨時存儲空間。 為什么我們需要緩沖區&#xff1f;原因很簡單&#xff0c;當數據量很大時&#xff0c;因為計算機無…

解決:Every derived table must have its own alias

前些天發現了一個巨牛的人工智能學習網站&#xff0c;通俗易懂&#xff0c;風趣幽默&#xff0c;忍不住分享一下給大家。點擊跳轉到教程。 報錯&#xff1a; com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Every derived table must have its own alias 解決&…

網絡爬蟲--20.【Scrapy-Redis實戰】分布式爬蟲獲取房天下--代碼實現

文章目錄一. 案例介紹二.創建項目三. settings.py配置四. 詳細代碼五. 部署1. windows環境下生成requirements.txt文件2. xshell連接ubuntu服務器并安裝依賴環境3. 修改部分代碼4. 上傳代碼至服務器并運行一. 案例介紹 爬取房天下&#xff08;https://www1.fang.com/&#xff…

同一臺電腦安裝python2python3

【安裝之前&#xff0c;先了解一下概念】 python是什么&#xff1f; Python是一種面向對象的解釋型計算機程序設計語言&#xff0c;由荷蘭人Guido van Rossum于1989年發明&#xff0c;第一個公開發行版發行于1991年。 Python是純粹的自由軟件&#xff0c; 源代碼和解釋器CPytho…

程序員的常見健康問題

其實這些問題不僅見于程序員&#xff0c;其他長期經常坐在電腦前的職場人士&#xff08;比如&#xff1a;網絡編輯、站長等&#xff09;&#xff0c;都會有其中的某些健康問題。希望從事這些行業的朋友&#xff0c;對自己的健康問題&#xff0c;予以重視。以下是全文。 我最近…

Java中BufferedReader和InputStreamReader

BufferedReader 類BufferedReader 由Reader類擴展而來&#xff0c;提供通用的緩沖方式文本讀取&#xff0c;而且提供了很實用的readLine&#xff0c;讀取一個文本行&#xff0c;從字符輸入流中讀取文本&#xff0c;緩沖各個字符&#xff0c;從而提供字符、數組和行的高效讀取。…

網絡爬蟲--21.Scrapy知識點總結

文章目錄一. Scrapy簡介二. Scrapy架構圖三. Scrapy框架模塊功能四. 安裝和文檔五. 創建項目六. 創建爬蟲一. Scrapy簡介 二. Scrapy架構圖 三. Scrapy框架模塊功能 四. 安裝和文檔 中文文檔&#xff1a;https://scrapy-chs.readthedocs.io/zh_CN/latest/intro/tutorial.html …

Spring 定時任務的幾種實現

前些天發現了一個巨牛的人工智能學習網站&#xff0c;通俗易懂&#xff0c;風趣幽默&#xff0c;忍不住分享一下給大家。點擊跳轉到教程。 近日項目開發中需要執行一些定時任務&#xff0c;比如需要在每天凌晨時候&#xff0c;分析一次前一天的日志信息&#xff0c;借此機會整…

trie樹(字典樹)

trie樹學習 學習trie樹 轉載于:https://www.cnblogs.com/cjoierljl/p/9317023.html

Vue 教程第四篇—— Vue 實例化時基本屬性

實例元素 el 實例元素指的是 Vue 實例化時編譯的容器元素&#xff0c;或者說是 Vue 作用的元素容器 <div id"app"></div> var vm new Vue({el: #app}) 也可以為實例元素指定其它選擇器 <div class"app"></div> var vm new Vue({…