deleted = "O“ var result = data.filter({ !$0.hasPrefix(deleted) }) result.sort({count($0) < count($1)}) Swift let data = ["Apple", "Microsoft", "Google", "Oracle", "Dell"]; let deleted = "O"; let mut result : Vec<&&str> = data.iter().filter(|s| !s.starts_with(deleted)).collect(); result.sort_by(|l, r|l.chars().count().cmp(&r.chars().count())); Rust auto data = ["Apple", "Microsoft", "Google", "Oracle", "Dell"]; const deleted = 'O'; auto result = data.filter!(s => s[0] != deleted).array; result.sort!((l, r)=>l.length < r.length); D val data = array("Apple", "Microsoft", "Google", "Oracle", "Dell") val deleted = 'O' val result = data.filter{it[0] != deleted} sortBy{it.length} Kotlin NSArray *data = [NSArray arrayWithObjects:@"Apple", @"Microsoft", @"Google", @"Oracle", @"Dell", nil]; NSString *deleted = @"O"; NSIndexSet *filteredIndexes = [data indexesOfObjectsPassingTest: ^(id obj, NSUInteger idx, BOOL *stop){return (BOOL)![obj hasPrefix:deleted];}]; NSArray *result = [[data objectsAtIndexes:filteredIndexes] sortedArrayUsingComparator: ^(id l,id r){ NSNumber *lLength = [NSNumber numberWithUnsignedInteger:[l length]]; NSNumber *rLength = [NSNumber numberWithUnsignedInteger:[r length]]; return [lLength compare:rLength]; }]; Objective-C $data = 'Apple', 'Microsoft', Google', 'Oracle', 'Dell' $deleted = 'O' $result = $data | ?{$_ -notlike "$deleted*"} | Sort-Object Length Powershell vector<string> data = { "Apple", "Microsoft", "Google", "Oracle", "Dell" }; auto deleted = 'O'; auto newEnd = remove_if(data.begin(), data.end(), [&](auto s) { return s[0] == deleted; }); data.erase(newEnd, data.end()); sort(data.begin(), data.end(), [](auto l, auto r) { return l.size() < r.size(); }); C++