-
Code sort=lambda x:"".join(list(filter(str.isalpha,sorted(x)))+list(filter(str.isdigit,sorted(x))))
Test Cases import codewars_test as test # TODO Write tests import solution # or from solution import example # test.assert_equals(actual, expected, [optional] message) .describe("Tests") def test_group(): .it("dcba") def test_case0(): test.assert_equals(sort("dcba"), "abcd") .it("LNabcdMOP") def test_case1(): test.assert_equals(sort("LNabcdMOP"), "LMNOPabcd") .it("AD2A3S4KB6k781bjasf") def test_case2(): test.assert_equals(sort("AD2A3S4KB6k781bjasf"), "AABDKSabfjks1234678") .it("KJBOkjASFIBUaf6") def test_case3(): test.assert_equals(sort("KJBOkjASFIBUaf6"), "ABBFIJKOSUafjk6") .it("KJs&g54%3do12bLS@8765AD$Flj") def test_case4(): test.assert_equals(sort("KJs&g54%3d99o512bLS@85AD$Flj"), "ADFJKLSbdgjlos1234555899") .it("kb1342sADS6!#%*(&#%!234Fgb;*&^!#%lbj8K4(&!@5A*BFDSK9756LB") def test_case5(): test.assert_equals(sort("kb1342sADS6!#%*(&#%!234Fgb;*&^!#%lbj8K4(&!@5A*BFDSK9756LB"), "AABBDDFFKKLSSbbbgjkls122334445566789")
Output:
-
Code def sort(x): z=lambda y: sorted(filter(y, x)); return ''.join(z(str.isalpha) + z(str.isdigit))- sort=lambda x:"".join(list(filter(str.isalpha,sorted(x)))+list(filter(str.isdigit,sorted(x))))
- All
- {{group.name}} ({{group.count}})
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}