Open main menu

A Proxy Sorter is a special technique that can be used to apply custom sorting in a pool.

ImplementationEdit

Here's a possible implementation with UCP Scripting Syntax

#name "Proxy Sorter example"

// This example shows how to apply custom sorting
// to a pool with national teams

comp WorldCup {

// let's imagine we have a pool with 4 random national teams
pool "Source pool" @src teams 4 {
    getRandomNationalTeam(International, 1)
}

// now we want to sort them in alphabetical order
// to do this, we need to create 2 helper pools -
// a pool, where all national teams are sorted in alphabetical order
// and a Proxy pool, which will be used to get a resulting pool
//----------------------------------------------------------------
pool "Sorted pool with all teams" @all_sorted teams 207 <- @src {
    getNationalTeam(Afghanistan)
    // ...
    getNationalTeam(Zimbabwe)
}

// add all teams from @all_sorted, except 4 teams from @src
pool "Proxy" @proxy teams 203 constraints @src <- @all_sorted {
    get(@all_sorted)
}
//----------------------------------------------------------------
// resulting pool - contains 4 teams from @all_sorted which are not
// present in @proxy (e.g. they are present in @src)

pool "Result pool" @dst teams 4 constraints @proxy <- @proxy {
    get(@all_sorted)
}

}