Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
1f31a33977
2 changed files with 20 additions and 0 deletions
|
@ -21,6 +21,8 @@ import (
|
|||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
// LayoutTable 描述了表格布局的结构。
|
||||
|
@ -174,6 +176,18 @@ func (value *Value) Compare(other *Value) int {
|
|||
}
|
||||
case KeyTypeTemplate:
|
||||
if nil != value.Template && nil != other.Template {
|
||||
if util.IsNumeric(value.Template.Content) && util.IsNumeric(other.Template.Content) {
|
||||
v1, _ := strconv.ParseFloat(value.Template.Content, 64)
|
||||
v2, _ := strconv.ParseFloat(other.Template.Content, 64)
|
||||
if v1 > v2 {
|
||||
return 1
|
||||
}
|
||||
|
||||
if v1 < v2 {
|
||||
return -1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
return strings.Compare(value.Template.Content, other.Template.Content)
|
||||
}
|
||||
case KeyTypeCheckbox:
|
||||
|
|
|
@ -18,6 +18,7 @@ package util
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
|
@ -82,3 +83,8 @@ func RemoveRedundantSpace(str string) string {
|
|||
}
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
func IsNumeric(s string) bool {
|
||||
_, err := strconv.ParseFloat(s, 64)
|
||||
return err == nil
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue