Sort by

recency

|

961 Discussions

|

  • + 0 comments
    vector<string> bigSorting(vector<string> unsorted) {
        std::sort(unsorted.begin(),
                  unsorted.end(),
                  [](const string& lhs, const string& rhs){
                      return lhs.length() == rhs.length() ? lhs < rhs : lhs.length() < rhs.length();
                  });
        return(unsorted);
    }
    
  • + 0 comments

    Big Sorting is something many students experience when trying to figure out their path forward, especially when preparing a university application. It feels like sorting through endless choices, from selecting the right courses to picking a campus that feels like home. Every step comes with decisions that can shape the future, and that’s where patience and clarity become important. The process may seem overwhelming, but breaking it down into smaller steps makes it manageable. Friends, mentors, and family can also help by sharing experiences and guidance along the way. In the end, Big Sorting is about finding direction and building confidence for the next chapter.

  • + 1 comment

    include

    using namespace std;

    int main(){ int n; cin >> n; vector unsorted(n); for(int unsorted_i = 0; unsorted_i < n; unsorted_i++){ cin >> unsorted[unsorted_i]; }

    sort(unsorted.begin(), unsorted.end(), [](const string& a, const string& b) {
        if (a.length() != b.length()) {
            return a.length() < b.length();
        }
        return a < b;
    });
    
    for (auto x:unsorted) cout << x << endl;
    
    return 0;
    

    }

  • + 0 comments

    I implemented my own mergesort in python but I was failing tests due to the conversion from str to int, and int to str.

    Fix? Simple, just run the mergesort with strings instead of ints.

  • + 0 comments
        public static List<String> bigSorting(List<String> unsorted) {
            unsorted.sort((a, b) -> {
                if (a.length() != b.length()) {
                    return Integer.compare(a.length(), b.length());
                } else {
                    return a.compareTo(b);
                }
            });
            return unsorted;
        }