truquesavançado
Classificação por verificação
Verifica se a matriz de entrada está ordenada em ordem crescente, decrescente ou desordenada. A lógica é implementada em uma Regra de Script personalizada.
David Škarka
Template author
This Complex Rule verifies the organization of data within a list. It analyzes an input array to determine if the elements are arranged in a specific sequence (ascending or descending), if they are equal, or if no sorting pattern exists.
Solution components
- A Scripting Rule named Check Sorting executes custom logic to assess the order of elements provided in the input.
- Input validation logic first checks the volume of data. If the input array contains fewer than two items, the rule returns a specific status indicating insufficient data to determine an order.
- Iterative comparison logic cycles through the array comparing adjacent elements:
- It ignores adjacent identical elements.
- It establishes an initial direction (ascending or descending) based on the first unequal pair found.
- If subsequent pairs contradict the established direction, the rule immediately identifies the list as "unsorted".
- Final status determination assigns a final output string based on the analysis:
- "ascending": If all comparable elements increase in value.
- "descending": If all comparable elements decrease in value.
- "all items are equal": If no difference in value was found across the entire array.
- "unsorted": If the elements follow no consistent order.
- "not enough items": If the array length is less than 2.
- Output formatting ensures the result is returned in the output field, while preserving the original data in the inputValues field for reference.
More Templates
See Other Templates
serviços financeirossugerido
Teste A/B
Descubra uma maneira simples de atribuir um grupo de teste para realizar testes A/B em suas decisões.
serviços financeirossugerido
Precificação baseada em risco
Descubra uma maneira simples de aplicar uma matriz de precificação baseada em risco adequada ao tipo de cliente.
serviços financeirossugerido
Critérios de Elegibilidade e Regras da Política
Descubra uma maneira simples de definir e executar vários conjuntos de regras e obter o resultado da decisão final.