Rearrange a string
Submissions: 3553   Accuracy:

51.61%

  Difficulty: Easy   Marks: 2

Given a string containing uppercase alphabets and integer digits (from 0 to 9), the task is to print the alphabets in the order followed by the sum of digits.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains a string with uppercase alphabets and integer digits.

Output:
Print alphabets in the order followed by the sum of digits.

Constraints:
1<=T<=10^5
1<=length of string<=10^5

Example:
Input:

2
AC2BEW3
ACCBA10D2EW30

Output:
ABCEW5
AABCCDEW6

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Ayush Govil
Author: Ayush Govil 1


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.