Skip to content

Commit

Permalink
Merge pull request #13 from coticom/main
Browse files Browse the repository at this point in the history
update sort rule
  • Loading branch information
coticom authored Mar 6, 2023
2 parents ac974fc + 7b34e78 commit d243914
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
23 changes: 19 additions & 4 deletions internal/app/model/dto/challenge_score.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,26 @@ func (p Scores) Less(i, j int) bool {
s3 := strings.ToUpper(p[i].TeamName)
s4 := strings.ToUpper(p[j].TeamName)

temp1 := []byte(p[i].TeamName)
temp2 := []byte(p[j].TeamName)
temp1 := []rune(p[i].TeamName)
temp2 := []rune(p[j].TeamName)

lcc1 := []byte(s3)
lcc2 := []byte(s4)
lcc1 := []rune(s3)
lcc2 := []rune(s4)
for i, _ := range lcc1 {
if !isLetterOrNum(lcc1[i]) {
lcc1[i] += 300
}

if lcc1[i] >= 48 && lcc1[i] <= 57 {
lcc1[i] += 100
}
}

for i, _ := range lcc2 {
if !isLetterOrNum(lcc2[i]) {
lcc2[i] += 300
}

if lcc2[i] >= 48 && lcc2[i] <= 57 {
lcc2[i] += 100
}
Expand Down Expand Up @@ -66,6 +74,13 @@ func (p Scores) Swap(i, j int) { p[i], p[j] = p[j], p[i] }

type Scores []ScoreRank

func isLetterOrNum(b rune) bool {
if (b >= 48 && b <= 57) || (b >= 65 && b <= 90) || (b >= 97 && b <= 122) {
return true
}
return false
}

type ScoreRank struct {
Rank int `json:"rank"`
TeamName string `json:"team_name"`
Expand Down
10 changes: 10 additions & 0 deletions internal/app/model/dto/scores_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package dto

import (
"testing"
)

func TestScores(t *testing.T) {
var scores []string
scores = append(scores, "")
}

0 comments on commit d243914

Please sign in to comment.