1+ /*
2+ * @Descripttion :
3+ * @Author : liujing
4+ * @Date : 2022-02-15 11:22:59
5+ * @LastEditTime : 2022-02-21 16:53:47
6+ */
17/**
28 * Helper tool,Improve and optimize development efficiency.
39 */
@@ -48,6 +54,23 @@ export function randomString(len = 32) {
4854 }
4955 return pwd ;
5056}
57+
58+ /**
59+ * Object array sort.
60+ * * @param arr
61+ * @type {boolean }
62+ */
63+ export function sortFun ( arr , props , type ) {
64+ if ( type == 1 ) {
65+ return arr . sort ( function ( a , b ) {
66+ return a [ props ] - b [ props ] ;
67+ } ) ;
68+ } else if ( type == 0 ) {
69+ return arr . sort ( function ( a , b ) {
70+ return b [ props ] - a [ props ] ;
71+ } ) ;
72+ }
73+ }
5174/**
5275 * integer decimals thousands format show
5376 * @type {boolean }
@@ -60,14 +83,14 @@ export function integerDecimalsFormat(num) {
6083 let intPart = num . substring ( 0 , pointIndex ) ;
6184 let pointPart = num . substring ( pointIndex + 1 , num . length ) ;
6285 intPart = intPart + "" ;
63- var re = / ( - ? \d + ) ( \d { 3 } ) / ;
86+ let re = / ( - ? \d + ) ( \d { 3 } ) / ;
6487 while ( re . test ( intPart ) ) {
6588 intPart = intPart . replace ( re , "$1,$2" ) ;
6689 }
6790 num = intPart + "." + pointPart ;
6891 } else {
6992 num = num + "" ;
70- var re = / ( - ? \d + ) ( \d { 3 } ) / ;
93+ let re = / ( - ? \d + ) ( \d { 3 } ) / ;
7194 while ( re . test ( num ) ) {
7295 num = num . replace ( re , "$1,$2" ) ;
7396 }
0 commit comments