WIP: feat: Change soring behaviour and add new testcase

This commit is contained in:
Alivecow 2024-11-21 16:56:28 +01:00
parent bad946e9ac
commit b63dc86c7e
2 changed files with 66 additions and 9 deletions

View file

@ -324,17 +324,20 @@ impl PartialEq for Polynomial {
}
impl PartialOrd for Polynomial {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
if self.polynomial.len() != other.polynomial.len() {
return Some(self.polynomial.len().cmp(&other.polynomial.len()));
} else {
for (field_a, field_b) in self.as_ref().iter().rev().zip(other.as_ref().iter().rev()) {
match field_a.cmp(field_b) {
std::cmp::Ordering::Equal => continue,
other => return Some(other.reverse()),
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
match self.polynomial.len().cmp(&other.polynomial.len()) {
Ordering::Equal => {
for (field_a, field_b) in
self.as_ref().iter().rev().zip(other.as_ref().iter().rev())
{
match field_a.cmp(field_b) {
std::cmp::Ordering::Equal => continue,
other => return Some(other.reverse()),
}
}
Some(Ordering::Equal)
}
Some(Ordering::Equal)
other => Some(other),
}
}
}