Skip to content

ADD sort(arr,arr+n,comaprator) inbuilt c++ function #717

@sarimurrab

Description

@sarimurrab

Detailed Description

Add a program of sorting using inbuilt c++ sort function

Context

  1. More will get to know about the comparator function.
  2. How comparator function sort in lexical order and how to improve it.

Possible Implementation

bool compare(string a, string b)
{
    cout << "Comparing " << a << " and " << b << endl;
    if (a.length() == b.length())
        return a < b;
    return a.length() < b.length();
}

sort(arr, arr + n, compare);

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions