我有一个显示一些数据的材质 UI 表。我希望能够根据平均值从最低到最高对表格进行排序。有没有办法默认这样做?就像表格在浏览器中加载时一样。这是我的表格和一些数据。我希望显示的平均列按从最低到最高的顺序排序。所以平均数最低的人在上面
const data = [
{
Name: "A Person",
Attendence: [
{
date: "2019/12/01",
attendence: 1
},
{
date: "2019/12/02",
attendence: 1
},
{
date: "2019/12/03",
attendence: 0
},
{
date: "2019/12/04",
attendence: 0
},
{
date: "2019/12/05",
attendence: 0.25
},
{
date: "2019/12/06",
attendence: 0.75
},
{
date: "2019/12/07",
attendence: 0.25
},
{
date: "2019/12/08",
attendence: 0.25
},
{
date: "2019/12/09",
attendence: 0
},
{
date: "2019/12/10",
attendence: 0
},
],
]
function Register(props) {
const classes …Run Code Online (Sandbox Code Playgroud) 我正在编写一种用给定字符替换字符串中所有元音的方法,但它不适用于具有多个元音的字符串。它适用于“脚后跟”,但不适用于“你好”。请帮忙。我的代码如下:
public Boolean isVowel(char ch){
char ch2 = Character.toLowerCase(ch);
char[] vowels = {'a', 'e', 'i', 'o', 'u'};
for(int i = 0; i < vowels.length; i++){
if (ch2 == vowels[i]) {
return true;
}
}
return false;
}
public String replaceVowels(String phrase, char ch){
String newP = "";
for(int i = 0; i < phrase.length(); i++){
char c = phrase.charAt(i);
Boolean vowel = isVowel(c);
if(vowel){
newP = phrase.replace(c, ch);
}
}
return newP;
}
Run Code Online (Sandbox Code Playgroud)