Sort by

recency

|

963 Discussions

|

  • + 1 comment

    Came up with a solution that uses a map/dict of sizes (k) and its value is a list/array of the numbers with the same size (v). Sort the size keys and after sort the map/dict values with more than one item.

  • + 0 comments

    Compare length first

    If length is equal, then compare the lexicon

    bool cmp(string &a, string &b) { if(a.length() != b.length()) return a.length() bigSorting(vector unsorted) { sort(unsorted.begin(),unsorted.end(),cmp); return unsorted; }

  • + 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;
    

    }