Skip to content

Instantly share code, notes, and snippets.

View ShamilPP's full-sized avatar
🏠
Working from home

Shamil ShamilPP

🏠
Working from home
View GitHub Profile
@ShamilPP
ShamilPP / main.dart
Last active February 22, 2023 15:05
List of months sorting
void main() {
List<int> months = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
int userValue = 6; // Change value
months.sort((a, b) {
if (userValue <= a) {
return a.compareTo(b);
} else if (userValue <= b) {
return b.compareTo(a);
} else {
return a.compareTo(b);
@ShamilPP
ShamilPP / main.dart
Last active December 9, 2024 11:12
List order
void main() {
List<int> months = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
int userValue = 6; // Change value
months.sort((a, b) {
if (userValue <= a && userValue <= b) {
return a.compareTo(b);
} else {
return b.compareTo(a);
}
});